我正在尝试在Tabpanel下的box()中构建条形图。
这是我的代码:
col1 <- c('upto30', '31-45','46-60','61-75', '76abv')
col2 <- c(10,20,30,40,50)
ui <- shinyUI(dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
mainPanel(tabsetPanel(type = 'tab',
tabPanel("",
box("",
barplot(col2))))) )
))
server <- shinyServer(function(input,output){
})
shinyApp(ui,server)
我不知道为什么在运行应用程序时会出现这样的错误。任何人都可以帮助解决此错误“要写入的文本必须是长度为一的字符向量”?
非常感谢
也许您想在server
而不是ui
中绘制图:
library(shiny)
library(shinydashboard)
ui <- shinyUI(dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
mainPanel(tabsetPanel(type = 'tab'),
tabPanel("",
box("",
plotOutput("myPlot")))))
))
server <- function(input,output){
output$myPlot <- renderPlot(
barplot(col2)
)
}
shinyApp(ui,server)