####Q1

Q1 <- ggplot(subset(master1, !is.na(USDAcat)), 
             aes(x = USDAcat, 
                 y = FedAid, 
                 fill = FedAid)) +
  geom_bar(stat="identity", position = "stack")+
  coord_flip()+ 
  theme(axis.text.x = element_blank(),
        plot.background = element_blank(),
        panel.border = element_blank(),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.background =element_blank(),
        legend.key=element_rect(fill="white")) +
  labs (title = "USDAcat to FedAid Undergrads")

Q1

#Q2
#Undergrads
collegeClassUgs <- subset(master1, Classification %in% c("Freshman", "Sophomore","Junior", "Senior")) %>%
  group_by(USDAcat, Classification) %>%
  summarize(N = n()) %>%
  mutate(freq = N / sum(N),
         pct = round((freq*100), 0))
#ck for counts

#collegeClassUgs %>% group_by(USDAcat) %>% summarize(total = sum(pct))

a <- ggplot(collegeClassUgs, aes(x = USDAcat, y = pct, fill = Classification))+
  geom_col(position = "dodge2") +
  labs(x = "USDAcat",y = "Percent", fill = "Classification") +
  theme(legend.position = "top", 
        plot.background = element_blank(),
        panel.border = element_blank(),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.background =element_blank()) +
  labs (title = "USDAcat to Degree Completion Undergrads")

a

####Undergrads, USDAcat and College
collegeClassUgs <- subset(master1, Classification %in% c("Freshman", "Sophomore","Junior", "Senior")) %>%
  group_by(USDAcat, College) %>%
  summarize(N = n()) %>%
  mutate(freq = N / sum(N),
         pct = round((freq*100), 0))



#to check my work 
#collegeClassUgs %>% group_by(USDAcat) %>% summarize(total = sum(pct))

b <- ggplot(collegeClassUgs, aes(x = USDAcat, y = pct, fill = College)) + 
  geom_col(position = "dodge2") +
  labs(x = "USDAcat",y = "Percent", fill = "College") +
  theme(legend.position = "top",
        plot.background = element_blank(),
        panel.border = element_blank(),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.background =element_blank())+
labs (title = "USDAcat to College Undergrads")

b

#######Graduates
####Graduates, USDAcat and Classification

collegeClassGrads <- subset(master1, Classification %in% c("Graduate (Masters)","Doctoral", "Professional (Certificate Program)")) %>%
  group_by(USDAcat, Classification) %>%
  summarize(N = n()) %>%
  mutate(freq = N / sum(N),
         pct = round((freq*100), 0))

#collegeClassGrads %>% group_by(USDAcat) %>% summarize(total = sum(pct))

c <- ggplot(collegeClassGrads, aes(x = USDAcat, y = pct, fill = Classification))+
  geom_col(position = "dodge2") +
  labs(x = "USDAcat",y = "Percent", fill = "Classification") +
  theme(legend.position = "top",
        plot.background = element_blank(),
        panel.border = element_blank(),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.background =element_blank()) +
  labs (title = "USDAcat to DegreeCompletion Graduate")
c

####Graduates, USDAcat and College

collegeClassGrads1 <- subset(master1, Classification %in% c("Graduate (Masters)","Doctoral", "Professional (Certificate Program)")) %>%
  group_by(USDAcat, College) %>%
  summarize(N = n()) %>%
  mutate(freq = N / sum(N),
         pct = round((freq*100), 0))


#collegeClassGrads %>% group_by(USDAcat) %>% summarize(total = sum(pct))

d <- ggplot(collegeClassGrads1, aes(x = USDAcat, y = pct, fill = College)) +
  geom_col(position = "dodge2") +
  labs(x = "USDAcat",y = "Percent", fill = "College") +
  theme(legend.position = "top",
        plot.background = element_blank(),
        panel.border = element_blank(),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.background =element_blank()) +
  labs (title = "USDAcat to College Graduate") 

d

#########Q3
####Undergrads gender and degree completion
collegeClass2 <- subset(master1, Classification %in% c("Freshman", "Sophomore","Junior", "Senior")) %>%
  group_by(Gendercats, Classification) %>%
  summarize(N = n()) %>%
  mutate(freq = N / sum(N),
         pct = round((freq*100), 0))

#collegeClass2 %>% group_by(Gendercats) %>% summarize(total = sum(pct))

e <- ggplot(collegeClass2, aes(fill=Classification, y=N, x=Gendercats)) + 
  geom_bar(position="stack", stat="identity") + 
  theme(plot.background = element_blank(),
        panel.border = element_blank(),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.background =element_blank()) +
  labs (title = "Gender to Degree Completion Undergrads")

e

####Undergrads gender  and college

collegeClass3 <- subset(master1, Classification %in% c("Freshman", "Sophomore","Junior", "Senior")) %>%
  group_by(Gendercats, College) %>%
  summarize(N = n()) %>%
  mutate(freq = N / sum(N),
         pct = round((freq*100), 0))
#collegeClass3 %>% group_by(Gendercats) %>% summarize(total = sum(pct))


f <- ggplot(collegeClass3, aes(fill=College, y=N, x=Gendercats)) + 
  geom_bar(position="stack", stat="identity") +
  theme(plot.background = element_blank(),
        panel.border = element_blank(),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.background =element_blank())+
  labs (title = "Gender to College Undergrads")
f

###########Graduates Q3

####Graduates gender and degree completion
collegeClass4 <- subset(master1, Classification %in% c("Graduate (Masters)","Doctoral", "Professional (Certificate Program)")) %>%
  group_by(Gendercats, Classification) %>%
  summarize(N = n()) %>%
  mutate(freq = N / sum(N),
         pct = round((freq*100), 0))

#collegeClass2 %>% group_by(Gendercats) %>% summarize(total = sum(pct))



g <- ggplot(collegeClass2, aes(fill=Classification, y=N, x=Gendercats)) + 
  geom_bar(position="stack", stat="identity") +
  theme(plot.background = element_blank(),
        panel.border = element_blank(),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.background =element_blank()) +
  labs (title = "Gender to Degree completion Undergrads")

g

####grads gender and college

collegeClass3 <- subset(master1, Classification %in% c("Graduate (Masters)","Doctoral", "Professional (Certificate Program)")) %>%
  group_by(Gendercats, College) %>%
  summarize(N = n()) %>%
  mutate(freq = N / sum(N),
         pct = round((freq*100), 0))


#collegeClass3 %>% group_by(Gendercats) %>% summarize(total = sum(pct))


h <- ggplot(collegeClass3, aes(fill=College, y=N, x=Gendercats)) + 
  geom_bar(position="stack", stat="identity") +
  theme(plot.background = element_blank(),
        panel.border = element_blank(),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.background =element_blank())+
  labs (title = "Gender to Classification GRaduate")


h