Thanks for the pointer. I should have looked at variable values first!

It appears that libname contains the path to the library and then loading
the rda file is just a matter of constructing the path properly

On Mon, Sep 14, 2009 at 3:28 PM, cls59 <ch...@sharpsteen.net> wrote:

>
>
>
> Hi, I have seen the answer to this sometime before but I just can't find it
> again - pointers appreciated.
>
> I have a package that contains some data.frames saved as .Rda files in the
> data/ directory. When the package is loaded I would like to have them be
> available in the workspace (without the user having to explicitly load them
> using data(...)).
>
> If my package does not use a NAMESPACE, I can place data(varName) in
> .First.lib. However if I use NAMESPACES then the above line will fail when
> placed in .onLoad. I was thinking of doing something such as
> load'filename.Rda') but that would require me to know the path to the
> package in a platform independent way.
>
> Can anybody suggest how I can acheive this?
>
> Thanks,
>
> --
> Rajarshi Guha
>
> </quote
>
> You mentioned that you used something similar to:
>
> .First.lib <- function( libname, pkgname ){
>
>  data( varName )
>
> }
>
> And it didn't work when you attached a NAMESPACE to the package. If your
> .Rda files are stored in the data directory of the package, have you tried
> using:
>
> .First.lib <- function( libname, pkgname ){
>
>  data( varName, package = pkgname )
>
> }
>
>
> If that doesn't work, then system.file() may be used to explicity recover
> the location of your package data files:
>
> .First.lib <- function( libname, pkgname ){
>
>  data( system.file( 'data/myDataFile.Rda', package = pkgname )
>
> }
>
> Good luck!
>
> -Charlie
>
> -----
> Charlie Sharpsteen
> Undergraduate
> Environmental Resources Engineering
> Humboldt State University
> --
> View this message in context:
> http://www.nabble.com/loading-a-package-.Rda-file-at-package-load-time-tp25439508p25441073.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@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.
>



-- 
Rajarshi Guha
NIH Chemical Genomics Center

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to