Site icon R-bloggers

Hacker News Religion Poll

[This article was first published on R-Chart, 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.

Hacker News user post polls from time to time – the following code constructs a bar chart based upon the responses to a recent poll on the stated religious affiliation of Hacker news users (parsed straight from the site).  The chart above is as of the date of this post – users may still be voting.


library(XML)
u=’http://news.ycombinator.com/item?id=1486594′
DF=readHTMLTable(u)


# Clean up the data
data=DF[4]$`NULL`$V2
data=data[!is.na(data)]


# Remove the word ‘points’
data=gsub(‘ points’,”,data)


# Put in a matrix format
m=as.data.frame(t(array(data, dim=c(2,14))))


rownames(m)=m$V1
m=m[-1]


# Plot
par(las=2, mar=c(14, 4, 4, 2) + 0.1, cex=0.85)
barplot(t(m))
title(‘Hacker News Religion Poll’)
To leave a comment for the author, please follow the link and comment on their blog: R-Chart.

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.