I want to clean up my data but I'm quite new to R.
my code:
#library
library(dplyr)
library(shiny)
library(shinythemes)
library(ggplot2)
#Source
dataset <- read.csv("Wagegap.csv")
SFWage <- dataset %>% select(gender,JobTitle,BasePay,Year,)
clean <- na.omit(SFWage)
#UI
ui <- fluidPage(
theme = shinytheme("united"),
navbarPage("San Fransisco Wages",
tabPanel("Barplot",
mainPanel(
plotOutput("barplot")
)) ,
tabPanel("Table",
mainPanel(
dataTableOutput("table")
))
)
)
#server
server <- function(input, output){
output$barplot <- renderPlot({
ggplot(clean, aes(x = JobTitle, y = BasePay ))+
geom_bar(stat="Identity", width = 0.3, fill="orange")+
labs(x= "Jobs", y = "Wage", title = "Wage per job")
})
output$table <- renderDataTable({
clean
})
}
shinyApp(ui = ui, server = server)
I get this output for the table: Table Output
What I would like is the Jobtitle to be bundled and only seperated by the gender, and showing the average of the BasePay.
M - account clerk - averageBasePay - Year
F - account clerk - averageBasePay - Year
and so on for every job.
This data will be used to compare the wagegap between genders for every job given in the dataset.
P.S.
If someone also could tell me why the na.omit didnt work to clean up the empty genders, that would be amazing :)