literacy rates using semantics and R

June 19, 2013

(This article was first published on - R, and kindly contributed to R-bloggers)

Literacy Rates

Somehow I stumbled into the world of linked open data trying to pull information easily off of a wikipedia page without having to write a customer scrapper. Enter in dbpedia, semantic technologies and some wonderful R packages take care of the back-end coding.

The Research Group Data and Web Science at the University of Mannheim has exposed a SPARQL endpoint for the CIA Factbook

Using this and the following query, I was able to quickly pull the gender specific literacy rates:

PREFIX db: <>
PREFIX rdfs: <>
PREFIX foaf: <>
PREFIX d2r: <>
PREFIX owl: <>
PREFIX map: <file:/var/www/>
PREFIX xsd: <>
PREFIX factbook: <>
PREFIX rdf: <>

  DISTINCT ?label 
    ((?litMale - ?litFemale) AS ?litDiff)
  WHERE { 
    ?resource factbook:literacy_female ?litFemale;
      factbook:literacy_male ?litMale; 
      rdfs:label ?label .

What’s the next logical step after getting data back in tabular form?

Visualization* using ggplot2!

Female literacy rates are on the x-axis, male literacy rates on the y-axis, size of the country name represents the distance between the gender rates and the color of the country name is based on the relative “strength” of the gender differences.

Full code is available in a github repo: dataparadigms – SemanticR.

To leave a comment for the author, please follow the link and comment on their blog: - R. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)