Religious restrictions index: how do countries compare?
[This article was first published on R Chronicle, 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.
The Guardian DataBlog published yesterday an interesting article exploring graphically the religious intolerance across the world. The data are coming from a report published by Pew Research Center’s Forum on Religion and Public Life. I like the philosophy DataBlog a lot, providing the raw data for everyone to look at. Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
However, I felt that the visualization could be improved. First the data are longitudinal and no temporal representation is provided. So I downloaded the Google Spreadsheet and worked it in R with googleVis. googleVis is the R API to the Google graphic library.
The data are composed of two data type:
- The Government Restriction Index (GSI) [measures government laws, policies and actions that restrict religious beliefs or practices]
- The Social Hostilities Index (SHI) [measures acts of religious hostility by private individuals,organizations and social groups]
The R code is the following:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(xlsx) | |
library(googleVis) | |
# I downloaded the Excel file, cleaned the headers and worked a bit | |
# the column title. | |
da <- read.xlsx("~/Downloads/religion.xlsx", sheetName=1) | |
rownames(da) <- da$COUNTRY. | |
da <- da[,-1] | |
religion <- data.frame(country=rep(rownames(da), 3), | |
year=c(rep(2007, dim(da)[1]), rep(2009, dim(da)[1]), rep(2010, dim(da)[1])), | |
GRI=c(da$GRI_2007, da$GRI_2009, da$GRI_2010), | |
SHI=c(da$SHI_2007, da$SHI_2009, da$SHI_2010) | |
) | |
M <- gvisMotionChart(religion, idvar="country", timevar="year") | |
plot(M) |
I like it better to explore those data. Select a country of interest and follow it.
To leave a comment for the author, please follow the link and comment on their blog: R Chronicle.
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.