我有一个漂亮的仪表板,我想在其中使用我的pickerInput()
中的一个变量并创建一个图。问题是,如果我使用name
或snID
而不是input$DB
,就会创建绘图。但是当我使用input$DB
时,我得到:Warning: Error in table: all arguments must have the same length
library(shiny)
library(shinydashboard)
library(shinyWidgets)
library(ggplot2)
library(plotly)
ui <- dashboardPage(
header = dashboardHeader(title = "My dashboard"),
sidebar = dashboardSidebar(
uiOutput("dbs")
),
body = dashboardBody(
plotlyOutput("fn")
)
)
server <- function(input, output, session) {
sts<-c("Rev","Rev")
sID<-c("123","124")
snID<-c("23","34")
name<-c("s","d")
pe<-data.frame(sts,sID,snID,name)
output$dbs<-renderUI({
pickerInput("DB", "Select Database/s",
choices = c("name","snID"),
multiple = F,options = list(`actions-box` = TRUE),
selected = "name")
})
output$fn<-renderPlotly({
#2.2 MAKING A TABLE for public.exists
tbl<-table(pe[[input$DB]], pe$sts)
ggplotly(
ggplot(as.data.frame(tbl), aes(!!sym(input$DB), Freq, fill = sts))
)
})
}
shinyApp(ui, server)
发布于 2020-05-27 18:49:12
我怀疑你的output$fn
reactive在input$DB
有值之前就已经执行了。因此,添加
req(input$DB)
在反应开始的时候,你应该没问题。
在没有任何演示输入数据的情况下,很难确定。
https://stackoverflow.com/questions/62050302
复制相似问题