I have a Shiny application which should show dependency between numbers (column count
) and race
of workers in the Silicon Valley. I want that when I choose on the left side gender
, job category
and company
on the diagram will be shown count
of workers with different races
. Now my diagram has range for the count only from 0 to 1 and shows not correct diagram.
Here is my code:
library(shiny)
library(ggplot2)
library(dplyr)
bcl <- read.csv(file = "E:/country/data/reveal.csv", colClasses = c("character", "integer", "factor", "factor", "factor", "integer"), na.strings = c("na", "NA")) %>% na.omit()
ui <- fluidPage(
titlePanel("Silicon Valley Diversity Data"),
sidebarLayout(
sidebarPanel(
img(src = "silicon.png", height = 150, width = 250),br(),
em("Choose company, job category and gender"),br(),
radioButtons("genderInput", "gender",
choices = list("male" = "male",
"female" = "female"),
selected = "male"),
radioButtons("jobInput","Job category",
choices = c(
"First/Mid officials & Mgrs",
"Professionals",
"Administrative support",
"Sales workers"
),
selected = "Technicians"
),
selectInput("companyInput", "company",
choices = c("Adobe", "Cisco", "Facebook", "Google", "HP", "Intel", "Twitter"))
),
mainPanel(plotOutput("coolplot"),
br(), br(),
tableOutput("results"))
))
server <- function(input, output) {
output$coolplot <- renderPlot({
filtered <-
bcl %>%
filter(
gender == input$genderInput,
job_category == input$jobInput,
company == input$companyInput
)
ggplot(filtered, aes(race)) +
geom_bar(fill = "#9f3e74")
})
}
shinyApp(ui = ui, server = server)
Here is my app: