这是我使用Shiny制作的第一个应用程序,我的反应式绘图遇到了一些麻烦。我的最终目标是能够使用下拉菜单选择客户端A-D,然后在按下“更新”按钮时从散点图中的列(日期,ModResult)绘制数据点。现在,它返回“轴错误:没有位置是有限的”。 labData数据框有7列:“ Client.Name”是第1列,“ Date”是第4列,“ ModResult”是第7列。请让我知道是否还有其他信息可以帮助调试此错误!
谢谢!
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)
答案 0 :(得分:0)
稍加修改
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)