我想用ShinyApp创建条形图,应该有“ selectInput”来创建条形图。但无法生成该barplot。
数据:我有两列-收款人身份ID和年龄
代码:
library(shiny)
library(shinydashboard)
library(dplyr)
data <- data.frame(read.csv(d:/...filename.csv))
gA <- filter(data, data$age >= 30 & data$age < 40)
gB <- filter(data, data$age >= 40 & data$age < 50)
gC <- filter(data, data$age >= 50 & data$age < 60)
gD <- filter(data, data$age >= 60)
ui <- mainPanel(
tabsetPanel(
tabPanel(h5("Age group"),
selectInput("Age", "Select Age Group", choices = c("gA","gB","gC","gD"),
multiple = TRUE))
))
plotOutput("Age")
server <- shinyServer(function(input,output){
output$Age <- renderPlot({
barplot(data$Age, main = "Age groups", xlab = "Age")
})
})
有人可以帮我吗?