Skip to content

Instantly share code, notes, and snippets.

@finiterank
Last active August 29, 2015 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save finiterank/c988166d752809cb6620 to your computer and use it in GitHub Desktop.
Save finiterank/c988166d752809cb6620 to your computer and use it in GitHub Desktop.
Gender Parity Plot
library(plyr)
library(reshape2)
library(ggplot2)
edx <- read.csv("data//HMXPC13_DI_v2_5-14-14.csv")
#Gender parity by Country
gender.table <- ddply(edx, .(final_cc_cname_DI, gender), summarise, number = length(userid_DI))
levels(gender.table$gender) <- c("none", "female", "male", "other")
gender.table <- dcast(gender.table, final_cc_cname_DI ~ gender, value.var="number")
gender.table$parity <- gender.table$female / gender.table$male
ggplot(gender.table, aes(x=parity, y=reorder(final_cc_cname_DI,parity))) +
geom_point(size=5, shape=15, color="orangered") +
xlab(expression(frac(Females, Males))) +
ylab("Country")
#Grades versus Number of Chapters by Course
edx.nchapters.grade <- edx[,c("nchapters", "grade", "course_id")]
edx.nchapters.grade <- edx.nchapters.grade[complete.cases(edx.nchapters.grade),]
ggplot(edx.nchapters.grade, aes(nchapters, grade)) +
geom_point(alpha=1/5, position = "jitter") +
geom_smooth(method="lm", color="orangered", size=2) +
scale_y_continuous(limits=c(0, 1)) +
facet_grid(course_id ~ .) +
xlab("Number of chapters with which the Student interacted") +
ylab("Grade (>0)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment