I’m aware that you can publish spreadsheets on Google docs and then import them in R. However, let’s say I have a function or some code I want to read in R (like in the source function). How would you for example read in all this code stored on google docs?
https://docs.google.com/document/edit?id=1f11rcVs9AtVcgOyiP0lV04yq9hshVDIPx93lA0ItFvQ
I don’t think this has been published but it’s just to give an example.
Basically I want to:
-
Create a function in R (for comparability see example below)
-
Upload it on Google Docs and share it with anyone with the link so that I don’t have to log in through R or Google Docs etc…
-
Read it in through a command like source() wherever I want
My interest is not in reading data but in reading functions. It would make importing my own functions much quicker when I’m not on the same computer/server.
Any ideas?
Many thanks
P.S. Example of a function from statsmethods.net
mysummary <- function(x,npar=TRUE,print=TRUE) {
if (!npar) {
center <- mean(x); spread <- sd(x)
} else {
center <- median(x); spread <- mad(x)
}
if (print & !npar) {
cat("Mean=", center, "\n", "SD=", spread, "\n")
} else if (print & npar) {
cat("Median=", center, "\n", "MAD=", spread, "\n")
}
result <- list(center=center,spread=spread)
return(result)
}
It is most easily done with Dropbox – see here http://thebiobucket.blogspot.co.at/2012/05/source-r-script-from-dropbox.html
like so:
But you can either do it with Googledocs, like here http://thebiobucket.blogspot.co.at/2011/11/how-to-run-r-scripts-directly-out-of.html#more