My param in plumber API doens't work in hcaes highcharts. I get dplyr error.
I need to select a column using @param. Like df24hr[,partic24hr] but returns error.
My code...
#* Return interactive plot
#* @serializer htmlwidget
#* @param partic24h Tipo de particulado
#* @get /hist24hr
function(partic24h = 'pts'){
equipamentos_ser <- dbGetQuery(con, sql_ser)
equipamentos <- dbGetQuery(con, sql_eq)
equipamentos_ser$date <- as.POSIXct(equipamentos_ser$date)
equipamentos_ser$idequip <- as.factor(equipamentos_ser$idequip)
df24hrs <- merge(x = equipamentos_ser[,-1] %>% timeAverage(., avg.time = "15 min", type = "idequip", fill = TRUE),
y = equipamentos)
options(scipen = 13)
df24hrs$datestamp <- datetime_to_timestamp(df24hrs$date)
hchart(df24hrs, type = "scatter",
hcaes(x = datestamp,
y = df24hrs[,partic24h],
group = nome)) %>%
hc_xAxis(type = "datetime", tickmarkPlacement = "on",
title = list(text = 'Horário da Medição'),
dateTimeLabelFormats = list(day = '%H:%M:%S')) %>%
hc_yAxis(title = list(text = paste(partic24h)),
opposite = FALSE, labels = FALSE) %>%
hc_tooltip( pointFormat = 'Hora Medição: {point.x:%Y-%m-%d %H:%M:%S} <br>
Valor Medido = {point.y: .4f}')
}
ERROR:
<error/dplyr:::mutate_error>
Problem with mutate()
input y
.
x objeto 'df24hrs' não encontrado
i Input y
is df24hrs[, partic24h]
.
Backtrace:
- plumb(file = "hist24hr/hist24hr.R")$run()
- base::.handleSimpleError(...)
- dplyr:::h(simpleError(msg, call)) <simpleError in .getNamespace(pkg): tipo/comprimento inválido (symbol/0) na alocação de vetor>