I am trying to run the code below to give me two histograms side by side comparing the difference in wage between Never Married and Married people. The code does work but I am being told this is the wrong way of getting the answer. I am not sure how to filter the original wage dataset by marital status to include only married and never married without creating a new dataset.
#Create a histogram to summarize the wage column ONLY for Married people
Married <- subset(Wage,Wage$maritl=="2. Married")
#Using facets create two side by side wage histograms for married vs never married people
Never_Married <- subset(Wage,Wage$maritl=="1. Never Married")
hist(Never_Married$wage)
Married_NeverMarried <- full_join(Married,Never_Married)
ggplot(Married_NeverMarried,aes(x=wage))+
geom_histogram(binwidth=20,color="black",fill="white")+
facet_grid(.~maritl)
This code below seems to work using the original wage dataset but gives me all of the marriage statuses instead of just 2.
ggplot(Wage,aes(x=wage))+
geom_histogram()+
facet_grid(.~ maritl)
Thank you!!

