我正构建一个闪亮的应用程序,使用selectizeInput
从多个数据框中选择值。但我有点卡在中间。以下是我的示例代码。任何帮助,将不胜感激。
A <- read.csv(.............)
B <- read.csv(.............)
C <- read.csv(.............)
ui.R
ui <- shinyUI(
fluidPage(
fluidRow(column(12,
hichartOutput("BAR"))
),
selectizeInput('WhichOne', 'Select One',
choices = c('A', 'B', 'C'),
selected = 'all')
server.R
output$BAR <- renderHighchart({
mydata <- input$WhichOne
hc <- highchart() %>%
hchart(mydata, 'bar', hcaes(x = ok, y = LikePercent))
基本上,我的高图将取决于用户选择哪个数据框。
非常感谢!
答案 0 :(得分:0)
如果没有可重复的示例,很难帮助您。但这可以帮助你开始:
data_sets <- list(A, B, C)
ui <- fluidPage(
selectInput('dataset', 'Choose a dataset:', choices = c("A" = "1", "B" = "2", "C" = "3")),
highchartOutput('my_plot')
)
server <- function(input, output, session) {
datasetInput <- reactive({
temp <- data.frame(data_sets[[as.numeric(input$dataset)]])
})
output$my_plot <- renderHighchart({
mydata <- datasetInput()
hc <- highchart() %>%
hchart(mydata, 'bar', hcaes(x = ok, y = LikePercent))
hc
})
}
shinyApp(ui, server)