Site icon R-bloggers

Data visualisation challange at useR 2014 conference

[This article was first published on SmarterPoland » PISA in english, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Familiar with R and DataVis? Take a try in PISA data visualisation contest for useR2014 participants.
There are two contest tracks. In each you can win 700$.

More information about the contest can be found here: http://www.oecd.org/pisa/pisaproducts/datavisualizationcontest.htm.

The prizes are funded by The Organisation for Economic Co-operation and Development (OECD) and tracks are related to data from The Programme for International Student Assessment (PISA).

Note that the deadline is Sunday 29 june 2014 Pacific Daylight Time.

Below you can find an simple example how to read PISA data and plot some basic graphs.

Let’s see in which countries pupils have high average reading + math score and in which countries pupils are on average better in math than reading.

library(ggplot2)
# read students data from PISA 2012
# directly from URL
con <- url("http://beta.icm.edu.pl/PISAcontest/data/student2012.rda")
load(con)
# calculate weighted mean from math / reading scores
# W_FSTUWT stands for final weights
mathScores <- unclass(by(student2012[,c("PV1MATH", "W_FSTUWT")], 
                 student2012$CNT,
                 function(x) weighted.mean(x[,1], x[,2])) )
readScores <- unclass(by(student2012[,c("PV1READ", "W_FSTUWT")], 
                 student2012$CNT,
                 function(x) weighted.mean(x[,1], x[,2])) )
# create a data.frame with scores and country names
# remove names with ( in name)
readMathScores <- data.frame(Country=names(readScores), readScores, mathScores)
readMathScores <- readMathScores[-grep(readMathScores$Country, pattern="(", fixed=TRUE),]
 
ggplot(readMathScores, aes(x=mathScores + readScores, y = mathScores - readScores, label = Country)) + 
  geom_text() +
  theme_bw()

Let’s add country sizes to the plot.

sizeScores <- unclass(by(student2012[,"W_FSTUWT"], 
                         student2012$CNT,
                         sum) )
# create a data.frame with scores, sizes and country names
# remove names with ( in name)
readMathScores <- data.frame(Country=names(readScores), readScores, mathScores, sizeScores)
readMathScores <- readMathScores[-grep(readMathScores$Country, pattern="(", fixed=TRUE),]
 
ggplot(readMathScores, aes(x=mathScores + readScores, y = mathScores - readScores, label = Country, size = sqrt(sizeScores))) + 
  geom_text() +
  theme_bw() + theme(legend.position="none")

I am very eager to see winning submissions.

To leave a comment for the author, please follow the link and comment on their blog: SmarterPoland » PISA in english.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.