Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Question2 :which states provides higher average salary for data-related jobs?
##2.1 Create a table for salary mapping
Salary_state= filter(SalaryData_Join,JOB_TITLE_SUBGROUP %in% c("data scientist","data analyst","business analyst")) %>%
group_by(WORK_STATE) %>%
summarise(Avg_pay=mean(PAID_WAGE_PER_YEAR))
Salary_table=inner_join(Salary_state,States,by=c("WORK_STATE"="Abr"))
Salary_table=Salary_table[,-c(5,6)]
##2.2 mapping the salary on USA_State Map using continuous color
Salary_table$state.name=tolower(Salary_table$state.name)
mapdata=map_data("state")
Salary_table_join=inner_join(Salary_table,mapdata,by=c("state.name"="region"))
g1=ggplot(data = Salary_table_join,aes(x=long,y=lat))
graph2=g1+geom_polygon(aes(color="darkblue",group = group,fill=Avg_pay),show.legend = F) +
scale_fill_continuous(low ="orange", high = "darkblue")+
ggtitle("Average Salary for Data-related job Across USA(sample)")
plot(graph2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.