【发布时间】:2015-12-08 04:59:46
【问题描述】:
我对 Shiny 和 R 有一些运气,但我无法使用 selectInput 函数来更改数据框。我可能遗漏了一些明显的东西,但这是我的代码
require(shiny)
A <- data.frame(x=c(1,2,3),y=c(3,2,1))
B <- data.frame(x=c(1,1,5),y=c(3,5,0))
ui <- fluidPage(
selectInput("df", "Select dataframe", choices = c('A'='A','B'='B'), selected = 'A'),
plotOutput("Plot")
)
server <- function(input, output)
{
df <- reactive({
x <- as.data.frame(input$df)
})
output$Plot <- renderPlot({
df <- df()
plot(x=df$x, y=df$y)
})
}
shinyApp(ui = ui, server = server)
我错过了什么?
【问题讨论】: