You can do the same thing with source code stored on GitHub. Hadley Wickham has actually made the whole process easier by combining the
source commands into one function:
source_url. This is in his devtools package.
Imagine we have a .R source code file like this:
# Make cars scatter plot<br />library(ggplot2)<br />Plot <- qplot(cars$dist, cars$speed) +<br /> theme_bw()<br />print(Plot)<br />
It is hosted on GitHub with the URL: https://raw.github.com/christophergandrud/christophergandrud.github.com/master/SourceCode/CarsScatterExample.R
So to run this source code directly in R all we need to type is:
library(devtools)<br />SourceURL <- "https://raw.github.com/christophergandrud/christophergandrud.github.com/master/SourceCode/CarsScatterExample.R"<br />source_url(SourceURL)<br />
There you go.
You can also directly source GitHub gists (which are nice for sharing short bits of code) with the