Install the ISLR package, load the tidyverse and ISLR package and Wage data.
library(ISLR)
library(tidyverse)
data(Wage)
ggplot(Wage, aes(age, wage)) + geom_point(aes(color = education, fill = education))
library(Hmisc)
census_term1 <- read_csv("https://raw.githubusercontent.com/bpattizUCM/MidAIR2017/master/Census%20Term1.csv") %>%
filter(!is.na(ACT)) %>%
mutate(ACT_GROUP = cut2(ACT, g = 4))
head(census_term1 %>% select(ID, ACT, ACT_GROUP))
## # A tibble: 6 x 3
## ID ACT ACT_GROUP
## <int> <int> <fctr>
## 1 1 21 [20,23)
## 2 2 19 [12,20)
## 3 3 26 [25,35]
## 4 4 20 [20,23)
## 5 5 21 [20,23)
## 6 6 24 [23,25)
Create a boxplot of HS_GPA and ACT_GROUP. Fill by ACT_GROUP, change the x-axis label to “ACT” and the y-axis to “High School GPA”give it a title called “High School GPA by ACT”. Center the title using the followign command: theme(plot.title = element_text(hjust = 0.5))
ggplot(census_term1, aes(ACT_GROUP, HS_GPA)) + geom_boxplot(aes(fill = ACT_GROUP)) + xlab("ACT") + ylab("High School GPA") + ggtitle("High School GPA by ACT") + theme(plot.title = element_text(hjust = 0.5))
ggplot(census_term1, aes(Hours)) + facet_wrap(~factor(Stype)) + geom_histogram(binwidth = 0.95)
data(College)
College_DF <-
College %>%
rownames_to_column("College") %>%
select(College, Enroll)
Change the y-axis label to “Enrollment”. Give it the black and white theme. Create a caption to give credit to the US News and World Report.
Missouri_Publics <-
College_DF %>%
filter(College %in% c("Central Missouri State University", "Southwest Missouri State University", "University of Missouri at Columbia")) %>%
mutate(College = case_when(College == "Central Missouri State University" ~ "UCM",
College == "Southwest Missouri State University" ~
"MSU",
College == "University of Missouri at Columbia" ~ "MU"))
ggplot(Missouri_Publics, aes(College, Enroll, fill = College)) + geom_bar(stat = "identity") + ylab("Enrollment") +
theme_bw() + labs(caption ="Source: 1995 US News and World Report")