[R] Where to put source code?

Sarah Goslee sarah.goslee at gmail.com
Sun Aug 23 00:32:14 CEST 2009

Or, even more simply: save your commands or functions in a file. You
can load them from R using:


On Sat, Aug 22, 2009 at 6:22 PM, Ron Burns<rrburns at cox.net> wrote:
> Peter-
> I use emacs and ESS.  Google r ess emacs and check out the first few hits.
> I use a split screen with the R file to edit on the left and get the R
> output on the right. Single line commands are executed with C-c C-n and
> selected regions are executed using C-c C-r as well as a bunch of other
> useful commands for R and, of course,  all of the editing power and
> functionality of emacs. I am using linux, but it is said to work fine on
> Windows.  There is an ESS help list too.
> HTH,
>  Ron
> Peter Meilstrup wrote:
>> 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
Sarah Goslee

More information about the R-help mailing list