Writing your own functions in R
One of the nice features in R is the ability to:
Write new functions in R
Write functions in R that perform many R functions in a sequence
It is convenient to work in an editor like emacs, try things out, find all the components needed to do the job and then save the set as an R function
(e.g., cup.measures).
Call R functions from a C program
Call C programs from an R function
Transcript
Next, we'll talk a little bit about writing your own functions in R, and I said earlier that you could think about running emacs, running a shell buffer within it, and typing in your R commands. And now, as you enter your commands, you can find out the sequence of commands you want to execute, group them into a function, name it, save it, and re-use that function.