[R] writing R extension

Sarah Goslee sarah.goslee at gmail.com
Wed Dec 20 21:06:08 CET 2006


Hi,

> I am dealing with the same issue here and I was wondering whether it would be possible to just save
> the R compliled function objects in a directory and just attach the directory to the search path.
> (I am using R2.4.0+ESS+Xemacs in windows XP).


The other method that I'm familiar with uses save() and load() rather than
attach. It may be possible to use attach() in some other method.

> temp1 <- function(x) {x * x}
> temp2 <- function(x) {x + x}
> temp1(3)
[1] 9
> temp2(3)
[1] 6
> save(list=ls(), file="testfns")
> q(save="no")

# start R
> ls()
character(0)
> load("testfns")
> ls()
[1] "temp1" "temp2"


My personal preference is the text source file approach, but opinions
obviously vary on that. I do keep "final" versions in a package.

And yes, the proper term is package, but it seems that if the entity
in question is stored in  /usr/lib/R/library (on my linux system), and
loaded with the function library() the occasional slip might be forgiven?

Sarah
-- 
Sarah Goslee
http://www.stringpage.com
http://www.functionaldiversity.org



More information about the R-help mailing list