当我在下面运行这个脚本时,它给了我两个分组的条形图。我只是想要一个向量,其中包含每组中的条数。附上快照以供参考,很明显,向量将有两个计数值。请帮忙。
library(shiny)
library(shinydashboard)
library(ggplot2)
library(plotly)
ui <- dashboardPage(
dashboardHeader(title = "Sankey Chart"),
dashboardSidebar(
width = 0
),
dashboardBody(
fluidRow(
column(10,
uiOutput('box1'),
tags$br()),
tags$br(),
column(10,
box(title = "Case Analyses",status = "primary",solidHeader =
T,width = 1050,height = 452,
plotlyOutput("case_hist"))
))
)
)
server <- function(input, output)
{
output$case_hist <- renderPlotly(
{
iris$iris_limits <- cut(iris$Sepal.Length, c(1,3,6,9))
iris$ID <- factor(1:nrow(iris))
gg <- ggplot(iris, aes(x=ID, y=Sepal.Length, fill=iris_limits)) +
geom_bar(stat="identity", position="dodge") +
facet_wrap(~iris_limits, scales="free_x", labeller=label_both) +
theme_minimal() + xlab("") + ylab("Sepal Length") +
theme(axis.text.x=element_blank())
ggplotly(gg)
}
)
output$box1 <- renderUI({
tagList(
infoBox("Total Cases", "a" , icon = icon("fa fa-briefcase"))
)
})
}
shinyApp(ui, server)