Friday, October 26, 2012

NSCB Sexy Stats Version 2

This was a revised version of my previous post about the NSCB article. With the suggestion from Tal Galili, below were the new pie charts and the R codes to produce these plots by directly scrapping the data from the webpage using XML and RColorBrewer pagkage.

Unemployment by Age Group

Unemployment by Gender

Unemployment by Civil Status

Unemployment by Educational Level


  1. 1) Cool, thanks.
    2) My name is Tal, not Tai :D
    (and if to linkback to anyplace, you can just link to my own blog:

    With regards :)

  2. I just tried to reproduce the beautiful pie charts, and it took me some twiddling.

    1) educ<-read.table("clipboard", header=T, sep="\t") didn't work correctly. It's always a bit awkward to make clipboard uses portable. The following snippet recreates the educ variable using portable code:

    Education <- c("Elementary", "High School", "College")
    Y2006 <- c(42.5, 47.7, 9.7)win.graph(w=14.3,h=7)
    Y2009 <- c(37.9, 52.2, 10)
    educ <- data.frame(Education, Y2006, Y2009)
    rm(Education, Y2006, Y2009)

    2) Talking about portability: You're on a Windows system, it seems, while I - fortunately - am not. Your use of win.graph(w=14.3,h=7) isn't portable. = 14.3, height = 7) should work on all platforms.

    3) I had to use "cex = 1" for the text calls, and "cex = 0.5" for the Data Source entry to keep the text within the visible plot area.

    Apart from portability aspects: Nice work!


    1. Hi Harald,

      Thanks for the comment. Will incorporate your suggestions on my next post!