[英]How to use multiple data.frame objects in one selectInput on shiny/ggplot2 app
我正在Windows 10 64bit上通過RStudio 0.99.491版使用R 3.2.3 ...我正在創建ggplot2閃亮的應用程序,該應用程序顯示氣泡圖。 我不明白我收到的錯誤消息,除了關於輸入的事實:
Warning in validateSelected(selected, choices, inputId) :
'selected' must be the values instead of names of 'choices' for the input 'month'
Warning: Error in ..stacktraceon..: object 'input' not found
Stack trace (innermost first):
1: shiny::runApp
Error in ..stacktraceon..({ : object 'input' not found
這是我正在使用的數據 。 這是代碼
用戶界面
library(shiny)
library(leaflet)
vars = c("april" = "April","may" = "May","june" = "June","july" = "July")
shinyUI(pageWithSidebar(
sidebarPanel(
selectInput("month", "Month", vars, selected = "april")),
mainPanel(plotOutput("plot")
)))
斷絕
library(shiny)
library(leaflet)
melt_april <- melt(april)
names(april) = c('departure', 'stop', 'frequency')
melt_may <- melt(may)
names(may) = c('departure', 'stop', 'frequency')
melt_june <- melt(june)
names(june) = c('departure', 'stop', 'frequency')
melt_july <- melt(july)
names(july) = c('departure', 'stop', 'frequency')
monthBy <- input$month
shinyServer( function(input, output){
observe({
output$plot <- renderPlot({
p <- ggplot(monthBy, aes(x = departure, y =stop, size = frequency, color = frequency)) +
geom_point()+
scale_colour_gradient(low="white",high="orange")+
print(p)
)
})
})
好吧,我認為您可能需要
monthBy <- input$month
在shinyServer
函數中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.