library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.0.2
## -- Attaching packages --------------------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2 v purrr 0.3.4
## v tibble 3.0.1 v dplyr 1.0.0
## v tidyr 1.1.0 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.5.0
## Warning: package 'ggplot2' was built under R version 4.0.2
## Warning: package 'readr' was built under R version 4.0.2
## Warning: package 'forcats' was built under R version 4.0.2
## -- Conflicts ------------------------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
college_data <- read_csv("http://672258.youcanlearnit.net/college.csv")
## Parsed with column specification:
## cols(
## id = col_double(),
## name = col_character(),
## city = col_character(),
## state = col_character(),
## region = col_character(),
## highest_degree = col_character(),
## control = col_character(),
## gender = col_character(),
## admission_rate = col_double(),
## sat_avg = col_double(),
## undergrads = col_double(),
## tuition = col_double(),
## faculty_salary_avg = col_double(),
## loan_default_rate = col_character(),
## median_debt = col_double(),
## lon = col_double(),
## lat = col_double()
## )
ggplot(data = college_data)+
geom_bar(mapping = aes(x= region, fill = control))
ggplot(data = college_data)+
geom_bar(mapping = aes(x= region, fill = control))+
theme(plot.background = element_rect(fill = "green") )
ggplot(data = college_data)+
geom_bar(mapping = aes(x= region, fill = control))+
theme(panel.background = element_rect(fill = "yellow") )
ggplot(data = college_data)+
geom_bar(mapping = aes(x= region, fill = control))+
theme(plot.background = element_blank() )+
theme(panel.background = element_blank() )
ggplot(data = college_data)+
geom_bar(mapping = aes(x= region, fill = control))+
theme(plot.background = element_blank() )+
theme(panel.background = element_blank() )+
theme(panel.grid.major = element_line(color = "Black"))
ggplot(data = college_data)+
geom_bar(mapping = aes(x= region, fill = control))+
theme(plot.background = element_blank() )+
theme(panel.background = element_blank() )+
theme(panel.grid.major.y = element_line(color = "Black"))
ggplot(data = college_data)+
geom_bar(mapping = aes(x= region, fill = control))+
theme(plot.background = element_blank() )+
theme(panel.background = element_blank() )+
theme(panel.grid.major.y = element_line(color = "Black"))+
ylab("Number of Schools")
ggplot(data = college_data)+
geom_bar(mapping = aes(x= region, fill = control))+
theme(plot.background = element_blank() )+
theme(panel.background = element_blank() )+
theme(panel.grid.major.y = element_line(color = "Black"))+
scale_x_discrete(name = "Region")+
scale_y_continuous(name = "Number of Schools", limits = c(0,500))
ggplot(data = college_data)+
geom_bar(mapping = aes(x= region, fill = control))+
theme(plot.background = element_blank() )+
theme(panel.background = element_blank() )+
theme(panel.grid.major.y = element_line(color = "Black"))+
scale_fill_manual(values = c("Green","Yellow"))
ggplot(data = college_data)+
geom_bar(mapping = aes(x= region, fill = control))+
theme(plot.background = element_blank() )+
theme(panel.background = element_blank() )+
theme(panel.grid.major.y = element_line(color = "Black"))+
scale_fill_manual(values = c("Green","Yellow"), guide=guide_legend(title = "Ins. Type"))
ggplot(data = college_data)+
geom_bar(mapping = aes(x= region, fill = control))+
theme(plot.background = element_blank() )+
theme(panel.background = element_blank() )+
theme(panel.grid.major.y = element_line(color = "Black"))+
scale_fill_manual(values = c("Green","Yellow"),
guide=guide_legend(title = "Ins. Type",
nrow = 1,
label.position = "top",
keywidth = 3))+
theme(legend.position = "top")
ggplot(data = college_data)+
geom_point(mapping = aes(x= tuition, y= sat_avg, color= control, size= undergrads),
alpha= 1/2)
ggplot(data = college_data)+
geom_point(mapping = aes(x= tuition, y= sat_avg, color= control, size= undergrads),
alpha= 1/2)+
annotate("text",label = "Elite", x= 48000, y = 1500)
ggplot(data = college_data)+
geom_point(mapping = aes(x= tuition, y= sat_avg, color= control, size= undergrads),
alpha= 1/2)+
annotate("text",label = "Elite", x= 48000, y = 1500)+
geom_hline(yintercept = mean(college_data$sat_avg))+
annotate("text",label = "Mean", x= 48000, y = mean(college_data$sat_avg)+22)
ggplot(data = college_data)+
geom_point(mapping = aes(x= tuition, y= sat_avg, color= control, size= undergrads),
alpha= 1/2)+
annotate("text",label = "Elite", x= 48000, y = 1500)+
geom_vline(xintercept = max(college_data$tuition))+
annotate("text",label = "Max", y= 1000, x = max(college_data$tuition)-2000)+
theme(plot.background = element_blank() )+
theme(panel.background = element_blank() )
ggplot(data = college_data)+
geom_point(mapping = aes(x= tuition, y= sat_avg, color= control, size= undergrads),
alpha= 1/2)+
annotate("text",label = "Elite", x= 48000, y = 1500)+
geom_vline(xintercept = max(college_data$tuition))+
annotate("text",label = "Max", y= 1000, x = max(college_data$tuition)-2000)+
theme(plot.background = element_blank() )+
theme(panel.background = element_blank() )+
ggtitle("sat_avg vs tuition",
subtitle= "U.S. Dept. of Education")
ggplot(data = college_data)+
geom_point(mapping = aes(x= tuition, y= sat_avg, color= control, size= undergrads),
alpha= 1/2)+
annotate("text",label = "Elite", x= 48000, y = 1500)+
theme_bw()
ggplot(data = college_data)+
geom_point(mapping = aes(x= tuition, y= sat_avg, color= control, size= undergrads),
alpha= 1/2)+
annotate("text",label = "Elite", x= 48000, y = 1500)+
theme_void()