我正在尝试制作一个R shiny
应用,该应用允许您选择一个组(性别,年龄,种族等),然后在每个级别的facet_wrap
中显示风险得分的直方图在那个小组中。例如,如果选择性别作为组,则直方图将具有针对男性和女性的方面。在下面的代码中,它不会产生任何方面。
library(shiny)
library(ggplot2)
# Define UI for miles per gallon app ----
ui <- fluidPage(
# Application title
titlePanel("Group fairness analysis"),# Sidebar
sidebarLayout(
sidebarPanel(
selectInput("group","Group:",c("Age" = "age","Gender" = "gender","Region" = "region","Ethnicity"="ethnicity"))
),# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
# Define server logic----
server <- function(input,output) {
output$distPlot <- renderPlot({
gg <- ggplot(df,aes(x=score))+
geom_histogram(breaks=seq(0,100,10))+
facet_wrap(~input$group)
gg
})
}
shinyApp(ui,server)