Skip to content

Instantly share code, notes, and snippets.

@simbamangu
Created January 29, 2012 14:59
Show Gist options
  • Save simbamangu/1699179 to your computer and use it in GitHub Desktop.
Save simbamangu/1699179 to your computer and use it in GitHub Desktop.
Reading mobile internet data for Tanzania from GDocs and examining in R
# RCurl needed for Google Docs access.
require(RCurl)
# The URL obtained by File|Publish to web then select csv:
u <- "https://docs.google.com/spreadsheet/pub?hl=en_GB&hl=en_GB&
key=0AmFzIcfgCzGFdHQ0eEU0MWZWV200RjgtTXVMY1NoQVE
&single=true&gid=4&output=csv"
con <- getURL(u, ssl.verifypeer=FALSE)
i <- read.csv(textConnection(con)) # Read the file.
plot(i$TSH.MB ~ i$TSH, col = as.numeric(i$Provider), pch = as.numeric(i$Provider), xlim = c(0,200000), ylim = c(0,50), xlab = "Bundle cost", ylab = "Cost per MB", cex = 2, axes = F)
axis(side = 1, pos= -1)
axis(side = 2, pos= -5000)
legend("topright", names(summary(i$Provider)), col = 1:5, pch = 1:5, cex = 1.2)
plot(i$TSH.MB ~ i$TSH, col = as.numeric(i$Provider), pch = as.numeric(i$Provider), xlim = c(0,100000), ylim = c(0,20), xlab = "Bundle cost", ylab = "Cost per MB", cex = 2, axes = F)
axis(side = 1, pos= -1, cex.axis = 0.6)
axis(side = 2, pos= -5000)
legend("topright", names(summary(i$Provider)), col = 1:5, pch = 1:5, cex = 1.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment