wicher
is a package used to make working with the WICHE enrollment
projections easier in R. We generally use WICHE enrollments to figure
out the percentage of students who participate in our assessments.
We also use WICHE to visualize demographics in our Excel dashboards so I'm putting some examples of visualizing in R below. I think this might make it easier to prototype the graphics before trying to work them into the dashboard.
You can install wicher
from it's github repository like
this:
# MAKE SURE YOU HAVE DEVTOOLS INSTALLED # AND REFERENCED install.packages("devtools") library(devtools) # USE DEVTOOLS TO INSTALL THE WICHE PACKAGE install_github('mattjcamp/wicher','mattjcamp') library(wicher) # REFERENCE GGPLOT2 install.packages("ggplot2") library(ggplot2)
You will need to install the packages above if you want to reproduce these examples.
wiche_graduate_projections
is the built in dataframe that comes with
this package. It looks like this:
library(wicher) library(tidyverse) head(wiche_enrollments)
Usually I use this dataframe to JOIN
to assessment
data aggregated by state and year to get participation rates, but sometimes
you may want to just lookup a few datapoints.
So I just started adding visualizations using R since we
mostly use Excel to produce graphics. Still, it's nice to
visualize data right in R while we are doing analysis. When I'm
not too worried about the appearence of the graphics I just use
qplot
(as in quick plot). This is part of ggplot2
that
we added at the top of this doc.
Here is how to do a quick line plot to show trends. So I pulled the
enrollments for White and Hispanic students in California for the
years 2000 to 2010. Then I used qplot
to make a chart that would
show the trend in enrollments for these two groups.
library(ggplot2) enrollments <- wiche_enrollments %>% filter(year %in% 2000:2010, location %in% "ca", race %in% c("white", "hispanic"), grade == "g") %>% arrange(year, race) qplot(year, n, data = enrollments, color = race, geom = c("point", "smooth"), main = "California Enrollment", xlab = "Academic Year", ylab = "Enrollment")
NOTE I found that these plots look terrible unless you set the right figure dimensions in the markdown code. Look at the code file to see how this is done.
Here is the same thing but using the full ggplot
function:
ggplot(enrollments, aes(x = as.character(year), y = n, group = race)) + geom_smooth(aes(color = race)) + geom_point(aes(color = race)) + ggtitle("California Enrollment") + labs(x = "Academic Year", y = "Enrollment")
NOTE I'm putting this here as a reference for when we want something like this and we want to control the output.
ggplot2
has more options thatqplot
.
Here is an example of using column charts to compare groups. We will look again at California at the beginning and the end of the trend examined above.
First, make the chart for 2005:
enrollments <- wiche_enrollments %>% filter(year %in% 2005, location %in% "ca", race %in% c("white", "asian", "hispanic", "native", "black"), grade == "g") %>% arrange(year, race) ggplot(data = enrollments, aes(race, n)) + geom_bar(stat = "identity", position = "dodge") + ggtitle("California Enrollment (2005)") + labs(x = "Academic Year", y = "Enrollment")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.