Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-27 Thread Simon Urbanek
On Feb 27, 2013, at 12:54 AM, Hervé Pagès wrote: > On 02/26/2013 05:28 PM, Simon Urbanek wrote: >> >> On Feb 26, 2013, at 6:48 PM, Hervé Pagès wrote: >> >>> On 02/26/2013 03:12 PM, Simon Urbanek wrote: On Feb 26, 2013, at 5:47 PM, Hervé Pagès wrote: > Hi, > > So MA

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-26 Thread Hervé Pagès
On 02/26/2013 05:28 PM, Simon Urbanek wrote: On Feb 26, 2013, at 6:48 PM, Hervé Pagès wrote: On 02/26/2013 03:12 PM, Simon Urbanek wrote: On Feb 26, 2013, at 5:47 PM, Hervé Pagès wrote: Hi, So MASS::huber(1:10) seems to do the job i.e. (1) loads the MASS package (if it's installed), (2) d

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-26 Thread Simon Urbanek
On Feb 26, 2013, at 6:48 PM, Hervé Pagès wrote: > On 02/26/2013 03:12 PM, Simon Urbanek wrote: >> >> On Feb 26, 2013, at 5:47 PM, Hervé Pagès wrote: >> >>> Hi, >>> >>> So MASS::huber(1:10) seems to do the job i.e. (1) loads the MASS >>> package (if it's installed), (2) does not pollute the sea

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-26 Thread Hervé Pagès
On 02/26/2013 03:12 PM, Simon Urbanek wrote: On Feb 26, 2013, at 5:47 PM, Hervé Pagès wrote: Hi, So MASS::huber(1:10) seems to do the job i.e. (1) loads the MASS package (if it's installed), (2) does not pollute the search path, (3) no 'R CMD check' warning if MASS is listed in Suggests, and

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-26 Thread Simon Urbanek
On Feb 26, 2013, at 5:47 PM, Hervé Pagès wrote: > Hi, > > So MASS::huber(1:10) seems to do the job i.e. (1) loads the MASS > package (if it's installed), (2) does not pollute the search path, > (3) no 'R CMD check' warning if MASS is listed in Suggests, > and (4) descent error message if MASS is

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-26 Thread Hervé Pagès
Hi, So MASS::huber(1:10) seems to do the job i.e. (1) loads the MASS package (if it's installed), (2) does not pollute the search path, (3) no 'R CMD check' warning if MASS is listed in Suggests, and (4) descent error message if MASS is not installed: > MASS::huber(1:10) Error in loadNamespa

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-26 Thread Milan Bouchet-Valat
Le lundi 25 février 2013 à 12:59 -0800, Davor Cubranic a écrit : > I haven't gotten any complaints from "R CMD check" when I used Simon's > suggestion, even with "--as-cran" flag. Hadley's suggestion to use > 'require' also works, and its side-effect of attaching the other > package can in some app

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-25 Thread Davor Cubranic
I don't see any warnings if MASS is listed in Suggests in the DESCRIPTION. Davor On 2013-02-25, at 1:28 PM, Hadley Wickham wrote: >> To summarize, it appears that the only way to call functions from a >> suggested package is by using either 'require' (which will dynamically >> attach it) or the

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-25 Thread Hadley Wickham
> loadNamespaces loads but does not attach the package. Suggests: is enough to > quieten the warning with > > ~/tmp$ R --version > R Under development (unstable) (2013-02-21 r62017) -- "Unsuffered > Consequences" > > This is consistent with RShowDoc("R-exts") section 1.1.1 > > Namespaces accessed

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-25 Thread Martin Morgan
On 02/25/2013 01:28 PM, Hadley Wickham wrote: To summarize, it appears that the only way to call functions from a suggested package is by using either 'require' (which will dynamically attach it) or the double colon method. Is this something that should be mentioned in R-exts? Except the double

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-25 Thread Hadley Wickham
> To summarize, it appears that the only way to call functions from a > suggested package is by using either 'require' (which will dynamically > attach it) or the double colon method. Is this something that should be > mentioned in R-exts? Except the double colon method doesn't work (i.e. does not

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-25 Thread Davor Cubranic
I haven't gotten any complaints from "R CMD check" when I used Simon's suggestion, even with "--as-cran" flag. Hadley's suggestion to use 'require' also works, and its side-effect of attaching the other package can in some applications be seen by the end user as a nice bonus, so I'll probably ha

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-25 Thread Davor Cubranic
On 2013-02-22, at 10:23 PM, Berwin A Turlach wrote: >> On Feb 22, 2013, at 6:39 PM, David Winsemius wrote: > [...] >>> I've always wondered: How does lattice manage to use grid functions >>> without putting them on the search path? > > Because lattice imports the grid package and has a NAMESPACE

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-22 Thread Berwin A Turlach
G'day David, On Fri, 22 Feb 2013 18:50:07 -0800 David Winsemius wrote: > On Feb 22, 2013, at 6:39 PM, David Winsemius wrote: [...] > > I've always wondered: How does lattice manage to use grid functions > > without putting them on the search path? Because lattice imports the grid package and ha

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-22 Thread Hadley Wickham
On Friday, February 22, 2013, Simon Urbanek wrote: > > On Feb 22, 2013, at 9:13 PM, Hadley Wickham wrote: > > > Hi Davor, > > > > To the best of my knowledge, there's only one way to use functions > > from a suggested package: with require: > > > > if (require("suggested_package")) { > > function

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-22 Thread Simon Urbanek
On Feb 22, 2013, at 9:13 PM, Hadley Wickham wrote: > Hi Davor, > > To the best of my knowledge, there's only one way to use functions > from a suggested package: with require: > > if (require("suggested_package")) { > function_from_suggested_package() > } else { > stop("suggested package not

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-22 Thread Mark Leeds
david: I was slightly misleading about the usefulness of that link for your question because it doesn't explicitly talk about the case where base packages import packages. But it talks about the general case of importing so hopefully base handles importing just like a package that would be install

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-22 Thread Mark Leeds
Hi David: According to the description on cran, lattice imports grid. I don't know if you've seen it but www.obeautifulcode.com has a very nice topic in its archives called "How R Searches and Finds Stuff" which is relatde to your question that I found it to be really helpful. A lot of people on

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-22 Thread David Winsemius
On Feb 22, 2013, at 6:39 PM, David Winsemius wrote: > > On Feb 22, 2013, at 6:13 PM, Hadley Wickham wrote: > >> Hi Davor, >> >> To the best of my knowledge, there's only one way to use functions >> from a suggested package: with require: >> >> if (require("suggested_package")) { >> function_f

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-22 Thread David Winsemius
On Feb 22, 2013, at 6:13 PM, Hadley Wickham wrote: > Hi Davor, > > To the best of my knowledge, there's only one way to use functions > from a suggested package: with require: > > if (require("suggested_package")) { > function_from_suggested_package() > } else { > stop("suggested package not

Re: [Rd] Recommended way to call/import functions from a Suggested package

2013-02-22 Thread Hadley Wickham
Hi Davor, To the best of my knowledge, there's only one way to use functions from a suggested package: with require: if (require("suggested_package")) { function_from_suggested_package() } else { stop("suggested package not installed") } Unfortunately I don't think there's any way to use a s

[Rd] Recommended way to call/import functions from a Suggested package

2013-02-22 Thread Davor Cubranic
If in my package "Foo" I call a function from another package "Bar" if it's available, according to R-exts, this sounds like I should include "Suggests: Bar" in package Foo's description. But the manual is silent on how to treat Bar's namespace. Should I import it? If so, should this be conditio