【发布时间】:2015-07-30 23:56:55
【问题描述】:
我正在尝试创建一个简单的闪亮应用程序,用户可以在其中从下拉菜单中选择一个变量,然后生成一个图。所选变量在服务器函数中被视为 input$Feature,但在尝试将数据框的列作为 df$input$Feature 访问时出现错误。我不知道该怎么做。
bw <- read.xls('filename')
ui <- fluidPage(
selectInput(inputId = 'Feature',
label = 'Select a feature to plot:',
c(colnames(bw))),
plotOutput('graph')
)
server <- function(input, output){
output$graph <- renderPlot({
p <- ggplot(bw, aes(bw$Date))
p <- p + geom_line(aes(y=bw$input$Feature, colour='red', group=1))
p <- p + labs(x = 'Date', y = 'Feature Name')
print(p)
})
}
shinyApp(ui=ui, server=server)
【问题讨论】: