Hacker News Religion Poll

July 5, 2010
By

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


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 his blog: R-Chart.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: 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...

Tags:

Comments are closed.