如何在Rhiny核心中使用updateselection()

问题描述 投票:0回答:1

我的RShiny中的脚本有问题。实际上该脚本有效,但是我有此错误/警告:

美学必须为长度1或与数据(1)相同:x,填充

您可以在[github](https://github.com/vladamihaesei/Rshiny_stripes_temperatures)上访问我的脚本

shiny updates shiny-server auto-update
1个回答
0
投票
library(shiny) library(shinythemes) library(ggplot2) library(dplyr) library(RColorBrewer) temp <- read.csv("Temperature_1961-2010.csv", stringsAsFactors = FALSE) col_strip <- brewer.pal(11, "RdBu") ui <- fluidPage(theme = shinytheme("darkly"), titlePanel("Temperature of Romania 1961-2010"), sidebarLayout( sidebarPanel( selectInput("RegiuneInput", "Regiune", choices = unique(temp$CMR)), selectInput("judetInput", "Judet", choices = unique(temp$NUME)) ), mainPanel(plotOutput("coolplot")) ) ) server <- function(input, output, session) { observeEvent(input$RegiuneInput, updateSelectInput(session, "judetInput", "Judet", choices = unique(temp$NUME[temp$CMR==input$RegiuneInput]))) output$coolplot <- renderPlot({ filtered1 <- temp %>% filter(CMR == isolate(input$RegiuneInput), NUME == input$judetInput) ggplot(filtered1, aes(x = Data, y = 1, fill = Temp))+ geom_tile() + scale_fill_gradientn(colors = rev(col_strip)) + guides(fill = guide_colorbar(barwidth = 1)) + theme_void() }) } shinyApp(ui = ui, server = server)
© www.soinside.com 2019 - 2024. All rights reserved.