0

I'm trying to create a dashboard for the airquality dataset with brushing capability in shinydashboard, but I keep getting "Error: need finite 'xlim' values". I can't figure out why as I went step by step from my text book. Can anyone advise? Below is my code...


library(shinydashboard)
library(datasets)

ui <- dashboardPage(
  dashboardHeader(title = "Brushing"),
  dashboardSidebar(collapsed = TRUE),
  dashboardBody(
    fluidRow(
      plotOutput("AirqualityPlot",
                 brush = "brushing"
      ),
      
      box((verbatimTextOutput("coords")),width = 12)
    )
  )
)

server <- function(input,output){
  output$AirqualityPlot <- renderPlot({
    plot(x=airquality$wind, y=airquality$temp,
         xlab = "Wind (mph)", ylab="Temperature(F)",
         pch=as.character(airqualityl$ozone))
  })
  
  output$coords <- renderPrint({
    brushedPoints(airquality, input$brushing,
                  xvar = "wind", yvar = "temperature")
    
  })

}
 
shinyApp(ui = ui, server = server)

I thought maybe because there are "NA" values in the airquality dataset, so I used tibble an tidy to eliminate the "NA" values, but there was no change in the result.

Rojo
  • 1
  • `pch = as.character(airqualityl$ozone))` likely contains two typos; besides: to add text to a base R plot, you'd use `text(...)` not `plot(..., pch=...)`. `pch` only specifies the point shape which *may* be a single letter. – I_O Mar 04 '23 at 00:20
  • I figured that the problem was in that part of the code. However, I pulled that right out of my textbook. The only difference is that the book was using a dataset on cereal in the Mass package. I deleted ```pch = as.character(airqualityl$ozone))``` altogether, but still get the same error. – Rojo Mar 04 '23 at 16:06
  • Your code works (well, does not throw an error) with the dataset `airquality` and its variable names (`names(airquality)`). After checking your code for typos (including capitalization), does the error persist? – I_O Mar 05 '23 at 08:17
  • Actually, I added xlim and ylim values and the error is gone. However, the plots are not showing up. – Rojo Mar 05 '23 at 16:50

0 Answers0