ScraperWikiExample
Jump to navigation
Jump to search
The code below fetches some WHO data from the ScraperWiki via its web API. The outcome should be equal to:
Try it out!
The code below fetches some WHO data from the ScraperWiki via its web API. The outcome should be equal to:
Try it out!
library(OpasnetBaseUtils)
library("xtable")
who_data = scraperwiki.json(name = "who_outbreaks", query = "select * from `swdata` order by `date` limit 10")
mat <- matrix(unlist(who_data), ncol=5, byrow=TRUE)
colnames(mat) <- names(who_data[[1]])
print(xtable(as.table(mat)), type="html", html.table.attributes="border=1 class='sortable'")
|
library(OpasnetBaseUtils)
library(xtable)
data = scraperwiki.json(name = "bbc_-_uk_military_deaths_in_afghanistan", query = paste("select",type,"from `swdata`"))
mat <- matrix(unlist(data), ncol=length(data[[1]]), byrow=TRUE)
#colnames(mat) <- names(data[[1]])
# the match
# i = match(type, names(data[[1]]))
#smoke <- as.table(mat)
#print(xtable(smoke), type="html", html.table.attributes="border=1 class='sortable'")
# Get the incident types column only this time
tab = table(mat[,1])
par(oma=c(0,14,0,0))
mp = barplot(sort(tab), main=paste("UK military deaths in Afghanistan -",type), horiz = TRUE,
ylab="", xlab="deaths", col=rainbow(nrow(tab)), las=1)
|