In my rms package I use the packagename:::functionname construct in a number of places. If I instead use the importFrom declaration in the NAMESPACE file would that require the package to be available, and does it load the package when my package loads? If so I would keep using packagename::: to avoid up-front loading of other packages that are not always used. Thanks Frank ----- Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/packagename-functionname-vs-importFrom-tp3172684p3172684.html Sent from the R help mailing list archive at Nabble.com.
Hi Frank, I think you mean packagename::functionname? The three colon form is for accessing non-exported objects. Otherwise, I think using :: vs importFrom is functionally identical - either approach delays package loading until necessary. Hadley On Mon, Jan 3, 2011 at 9:45 PM, Frank Harrell <f.harrell at vanderbilt.edu> wrote:> > In my rms package I use the packagename:::functionname construct in a number > of places. ?If I instead use the importFrom declaration in the NAMESPACE > file would that require the package to be available, and does it load the > package when my package loads? ?If so I would keep using packagename::: to > avoid up-front loading of other packages that are not always used. > > Thanks > Frank > > > ----- > Frank Harrell > Department of Biostatistics, Vanderbilt University > -- > View this message in context: http://r.789695.n4.nabble.com/packagename-functionname-vs-importFrom-tp3172684p3172684.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/
On Mon, Jan 3, 2011 at 3:48 PM, Hadley Wickham <hadley at rice.edu> wrote:> Hi Frank, > > I think you mean packagename::functionname? ?The three colon form is > for accessing non-exported objects.Normally two colons suffice, but within a package you need three to access exported but un-imported objects :) Peter
>> I think you mean packagename::functionname? ?The three colon form is >> for accessing non-exported objects. > > Normally two colons suffice, but within a package you need three to > access exported but un-imported objects :)Are you sure? Note that it is typically a design mistake to use ?:::? in your code since the corresponding object has probably been kept internal for a good reason. Consider contacting the package maintainer if you feel the need to access the object for anything but mere inspection. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/