hong shen
2009-Mar-25 01:07 UTC
[R] how to identify a symbol is defined from which package
Hi list, I encountered a situation that a data frame is defined by two packages. Both of them are loaded by library(). My questions are 1. How could I tell the data frame is from which package? 2. If I want to reference the data frame from package A insted of B, how can I do it? Thanks! hshen
Dieter Menne
2009-Mar-25 07:19 UTC
[R] how to identify a symbol is defined from which package
hong shen <hshen_1998 <at> yahoo.com> writes:> > I encountered a situation that a data frame is defined by two packages. Bothof them are loaded by library().> 2. If I want to reference the data frame from package A insted of B, how can Ido it? Either change the loading sequence of library(). Or, if you want both, use library(a) aFrame = theFrame library(b) bFrame = the Frame # This step not really required Dieter
Duncan Murdoch
2009-Mar-25 10:48 UTC
[R] how to identify a symbol is defined from which package
hong shen wrote:> Hi list, > > I encountered a situation that a data frame is defined by two packages. Both of them are loaded by library(). My questions are > > 1. How could I tell the data frame is from which package? >find("theName") will tell you where it found a variable called theName.> 2. If I want to reference the data frame from package A insted of B, how can I do it? >A::theName or B::theName will find whichever one you want. Duncan Murdoch> Thanks! > hshen > > ______________________________________________ > 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. >
A::thename works only when thename is exported by the name space A. A:::thename works only when thename is defined in the name space A. getAnywhere(thename)$objs$"package:A" always works. On Mar 25, 6:48?am, Duncan Murdoch <murd... at stats.uwo.ca> wrote:> hong shen wrote: > > Hi list, > > > I encountered a situation that a data frame is defined by two packages. Both of them are loaded by library(). My questions are > > > 1. How could I tell the data frame is from which package? > > find("theName") > > will tell you where it found a variable called theName. > > > 2. If I want to reference the data frame from package A insted of B, how can I do it? > > A::theName > > or > > B::theName > > will find whichever one you want. > > Duncan Murdoch > > > Thanks! > > hshen > > > ______________________________________________ > > R-h... at r-project.org mailing list > >https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.