library(ggplot2)
library(modeldata)HW2
Problem1
ggplot(attrition,
aes(x=MonthlyIncome,y=Education, fill = Education))+
geom_boxplot()+
scale_fill_brewer(palette = "Dark2")+
theme(legend.position = "none")+
labs(title = "Learn to earn",x = "Monthly Income")Problem 2
ggplot(attrition, aes(x=Age))+
geom_histogram(bins = 10, fill = "lightgreen", color= "black")Problem 3
ggplot(attrition,aes(x= JobSatisfaction, fill= Attrition))+
geom_bar()+
scale_fill_brewer(palette = "Dark2")Problem 4
ggplot(attrition,aes(fill = JobSatisfaction, x = Attrition))+
geom_bar()+
scale_fill_brewer(palette = "Dark2")Problem 5
library(dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
ggplot(attrition, aes(x = MonthlyIncome, fill = EducationField)) +
geom_histogram(binwidth = 1000, bins = 30) +
scale_fill_brewer(palette = "Dark2")+
labs(title = "Income by Field", x = "Monthly Income", y = "Count",caption =
"Source: IBM Watson Analytics Lab") +
theme(legend.position = "none")+
facet_wrap(vars(EducationField))