简体   繁体   中英

How to plot columns from reactive element in Shiny

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 AD 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)

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM