[R] Which should I use? system.file() path.package() find.package()

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue Apr 19 14:18:09 CEST 2011



On 19.04.2011 05:19, Kevin Wright wrote:
> For a package that I am creating, I have some files in the "inst"
> directory.  In the package man pages, I want to have R code that accesses
> these files.
>
> As of R-2.13.0, it looks like I can use any of: system.file() path.package()
> find.package()
>
> There are some differences between these functions, so I am wondering, is
> there is a preferred approach?

find.package() is the worst one: It will access all installed packages, 
that may be thousands and takes minutes...

path.package() is a non backward compatible function that makes use of 
system.file() and does not support to construct the full path to the 
file with one call.

Since you know the package is there after your loaded it successfully, 
just use

system.file()


Uwe Ligges


>
> Kevin Wright
>
> 	[[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.



More information about the R-help mailing list