[R] "source" command inside R package scripts

Hadley Wickham h.wickham at gmail.com
Tue Oct 21 23:03:20 CEST 2014


Your source function will be called when the package is _built_, not
when it's loaded/attached. There's almost certainly a better way to
solve your problem than using source() inside a package

Hadley

On Tue, Oct 21, 2014 at 6:24 AM, Enrico Bibbona <enrico.bibbona at unito.it> wrote:
> I have built a new package. I would like to put an R script (let us call it
> "script.R) into a subdirectory of the /pkg/R/ directory, called /pkg/R/sub/
> and I would like that such code is run when the package is installed.
>
> My way of doing so was to put an R script into /pkg/R/ with source command
> like
>
> source("./R/sub/script.R")
>
> that does not give me any error, but I know that the script (which
> actuallly defines a few functions is not run. What is wrong? What can I do
> better?
> Thanks, Enrico
>
> --
> Enrico Bibbona
> Dipartimento di Matematica
> Università di Torino
> https://sites.google.com/site/enricobibbona/
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
http://had.co.nz/



More information about the R-help mailing list