0

This is my first app that I am making using Shiny, and I am having some trouble with my reactive plot. My end goal is to be able to use the drop down menu to select client A-D and then plot the datapoints from the columns (Date, ModResult) in a scatterplot when the Update button is pressed. Right now it returns "Error in axis: no locations are finite." The labData data frame has 7 columns: "Client.Name" is column 1, "Date" is column 4, and "ModResult" is column 7. Please let me know if there is any more information that could help in debugging this error!

Thank you!

library(shiny)
ui <- fluidPage(titlePanel("Dilution History"),
  selectInput(inputId="client", label="Select Client Name", 
choices=levels(labData$Client.Name)), actionButton("update", "Update"), 
hr(),
  plotOutput("line")
)


server <- function(input, output, session){
#selected client into data frame
selDF <- reactive({data.frame(labData[labData[,1] =="input$client",])
  })   
  output$line <- renderPlot({
    plot(selDF()$Date, selDF()$ModResult, ylab="Result", main="Results 
For Client X Between Xdate and Ydate")
  })
}


shinyApp(ui = ui, server = server)
  • 1
    By best guess is `labData[,1] =="input$client" needs to be labData[,1] ==input$client`. If this is not the problem please attached some sample data so that we can debug it. – Sada93 Feb 18 '19 at 19:34
  • Welcome to SO Camellia, Your question can be best answered with a minimum reproducible example that should include a dummy data. https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – amrrs Feb 19 '19 at 04:37

1 Answers1

0

After few modifications

library(shiny)
ui <- fluidPage(titlePanel("Dilution History"),
                selectInput(inputId = "client", label = "Select Client Name", 
                            choices = levels(labData$Clientname)), submitButton("update"), 
                hr(),
                plotOutput("line")
)


server <- function(input, output, session){

selDF <- reactive({data.frame(labData[labData$Clientname == input$client,])
  })
  output$line <- renderPlot({
    plot(selDF()$date, selDF()$result, ylab = "Result", main = "Results For Client X Between Xdate and Ydate")
  })
}

shinyApp(ui = ui, server = server)
msr_003
  • 1,205
  • 2
  • 10
  • 25