There was a lot of really great stuff that Corey’s post encouraged me to explore, but one of the things that it required was to import some data directly from Corey’s github repository into R, and I thought I would quickly write a post on how that can be done.
Corey’s github repository can be found here, and in it there is a data folder that contains all the data required to replicate his time series forecast of bicycle collisions. Corey has also graciously provided R code for the later in the same repository.
To import the data, you will need to have the RCurl library installed.
library(RCurl) url <- 'https://raw.github.com/cjbayesian/collisions/timeseries/data/Bike%20Accidents.csv' bike.data <- getURL(url, ssl.verifypeer = FALSE) ## ssl.verifypeer is to subverte an SSL error you get otherwise d <- read.table(textConnection(bike.data), header=TRUE, sep='|', row.names='id', na.strings=' ') ## file uses bar separator
It’s as easy as that! Now if I can only get that pesky shapefile (montreal_borough_borders.shp) to play nicely with readShapePoly()! So much to learn, so little time! 🙂
OK, so I’ve revisited this as I start to implement a workflow that incorporates Git for version control and such… As I’ve done so, I wanted to post another set of example code:
url <- "https://raw.githubusercontent.com/connerpharmd/LDLCVE/master/secprevstatin.csv" statins <- getURL(url, ssl.verifypeer = FALSE) statins<- read.csv(textConnection(statins)) statins <- statins[ which(statins$Study != "AtoZ"),]