[R] How do I import packages with the package I've built?
Uwe Ligges
ligges at statistik.uni-dortmund.de
Sat Nov 17 18:04:16 CET 2007
There is a difference between importing a namespace and loading a package:
If you import functions from a namespace into your package, these
functions are known within that namespace, i.e. functions from your
package's namespace know the other functions and can use them. The user
still won't see those imported functions while working on the top level.
If you want the latter, you have to load the other package explicitly,
e.g. in your .onLoad directives.
Uwe Ligges
Nutter, Benjamin wrote:
> I have successfully completed building a package to contain the
> functions I commonly use. However, I need to have other packages
> installed in order for some of my functions to work. I've been studying
> the instructions on installing packages for about a month now, but still
> haven't figured this one out. From what I do understand, to import
> additional packages I need some combination of commands in my
> DESCRIPTION and NAMESPACE files. Currently, these are what mine look
> like:
>
> DESCRIPTION
> Package: myPackage
> Type: Package
> Title: Commonly used functions.
> Version: 1.0
> Date: 2007-11-08
> Author: My Name
> Maintainer: My Name <myfault at somewhere.net>
> Description: Blah Blah Blah
> License: R 2.3.0
> Depends: MASS, survival
>
>
> NAMESPACE
> export(func1, func2, ... , funcx)
>
> import(MASS, survival)
>
>
> These pass all the checks, and the package installs just fine, but it
> doesn't load MASS and survival when I load myPackage. What am I doing
> wrong?
>
> Benjamin
>
>
> P Please consider the environment before printing this e-mail
>
> Cleveland Clinic is ranked one of the top hospitals
> in America by U.S. News & World Report (2007).
> Visit us online at http://www.clevelandclinic.org for
> a complete listing of our services, staff and
> locations.
>
>
> Confidentiality Note: This message is intended for use\...{{dropped:13}}
>
> ______________________________________________
> 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