## ---- include = FALSE---------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 6, 
  fig.height = 4.5,
  warnings = FALSE,
  errors = FALSE
)

## ----setup, [encoded data, 9986 characters]
library(IPEDS)
library(dplyr)
library(ggplot2)

# Saves old options and declares new one for vignette
original_width <- options("width")
options(width=10000)

## [encoded data, 9997 characters]
head(complete2020)

## [encoded data, 9997 characters]
school_preferences(size = 2, region = "New England", alt_credits = "Yes", diversity_students = 36, financial_aid = 70, affiliation = 3)

## ---- [encoded data, 9992 characters]
school_preferences(size = 2, region = "New England", alt_credits = "Yes", diversity_students = 36, financial_aid = 70, affiliation = 3) %>% 
  select(`Institution`, `Institution Size`, `Region`, `Alternative Credit`, `Student Diversity`, `% of Students Recieved Aid`, `Type of Institution`)

## [encoded data, 9997 characters]
admission_reqs(167835)

## ---- [encoded data, 9992 characters]
data <- school_preferences()

ggplot(data, aes(x = `Staff Diversity`, y = `Student Diversity`)) +
  geom_point() +
  geom_smooth(method = "lm") +
  labs(title = "Student Diversity vs. Staff Diversity",
       y = "Student Diversity (%)",
       x = "Staff Diversity (%)")

## ---- [encoded data, 9992 characters]
data <- school_preferences(region = "New England")

ggplot(data, aes(x = `Staff Diversity`, y = `Student Diversity`)) +
  geom_point() +
  geom_smooth(method = "lm") +
  labs(title = "Student Diversity vs. Staff Diversity in New England Institutions",
       y = "Student Diversity (%)",
       x = "Staff Diversity (%)")

## ---- [encoded data, 9992 characters]
data <- school_preferences(region = "New England") %>% 
  filter(`Institution Size` != -1 &`Institution Size` != -2 )

data$`Institution Size` <- as.factor(data$`Institution Size`)

ggplot(data, aes(x = `Staff Diversity`, y = `Student Diversity`, color = `Institution Size`)) +
  geom_point() +
  scale_fill_viridis_c(option = "magma") +
  geom_smooth(method = "lm", aes(color=`Institution Size`), se = FALSE) +
  labs(title = "Student Diversity vs. Staff Diversity in New England Institutions by Size",
       y = "Student Diversity (%)",
       x = "Staff Diversity (%)")

## [encoded data, 9997 characters]

compare_int(100654, 100663)


## ---- include=FALSE-----------------------------------------------------------
# Resets user-level options
options(original_width)

