[R] Where to put source code?

Peter Meilstrup peter.meilstrup at gmail.com
Fri Aug 21 12:06:40 CEST 2009


I'm trying to move from Matlab to R, and I'm stuck even getting
started. This sounds to me like the dumbest question in the world
but... how does one put R source code in files? Over the last three
days I've gone front to back through the Introduction to R and the R
Language Definition, and while I'm excited that the language is so
Lispish, none of what I read described how to write a function, save
the source code in a file, and have it be usable other than directly
entering the function definition at the command prompt.

How do you edit your functions, where do you put the source files that
contain your functions, how do you tell R to use function definitions
from a particular file? How do you make incremental changes to your
functions while debugging?

I have not gone into the documentation about writing "packages" and
"extensions" other than to glance at them and decide that can't
POSSIBLY be the answer I'm looking for.

I'm just looking for the local equivalent of (in matlab) writing a
function, saving it as functionName.m and then being able to call
functionName(). Or in Python of writing a module.py and then typing
"import module" at the prompt.

Again this feels like an extraordinarily stupid question. But for some
weird reason I'm coming up with nothing in the FAQ or in Rseek.

Peter




More information about the R-help mailing list