I don't know very well about lattice but I know here the openair::timePlot function call lattice.xyplot to plot time series of pollutant concentrations.
I'd like to add ablines accordingly onto different panels. I successfully did it locally. But got error when use it in
Shiny.
Here are Shiny app code and screenshot.
The first abline using direct h=15 works, but second one get error
ps: 'mydata' is not MY data, it is included in Openair package
library(openair)
library(shiny)
library(latticeExtra)
ui <- fluidPage(
plotOutput("timePlot")
)
server <- function(input, output) {
output$timePlot <- renderPlot({
df <- selectByDate(mydata, year = 2003, month = 3)
timePlot(df, pollutant = c("so2", "co","pm25"),
y.relation = "free")
ref <- c(15, 1, 40)
trellis.last.object() +
layer(panel.abline(h = 15, lty = 5), rows = 1) +
layer(panel.abline(h = ref[2], lty = 5), rows = 2)
})
}
shinyApp(ui = ui, server = server)
Any help, Thanks!