[R] Using library in an example

Duncan Murdoch murdoch at stats.uwo.ca
Wed Jun 4 14:37:59 CEST 2008


On 6/4/2008 8:09 AM, Jim Lemon wrote:
> Hi all,
> I've been trying to include a nice example in the Rd file for a function 
> and cannot work out how to get it through R check. If I use:
> 
> if(require(maps,quietly=TRUE)) {
>   ...
> 
> Warning message:
> 'Sys.putenv' is deprecated.
> Use 'Sys.setenv' instead.
> See help("Deprecated")

require() doesn't use Sys.putenv, so I'd guess some package that you're 
loading does.  However, the current version of maps doesn't, so I think 
you must be loading something that's obsolete.

sessionInfo() would have helped a lot.

Duncan Murdoch

> 
> The warning message causes R check to get the tremors and assume there 
> is something wrong with the example. This also means that I can't put a 
> little message telling the user that they needed "maps" to run the 
> example, as the warning message leads to the "else" being detached from 
> the "if" (and another tremor and error message).
> 
> I can't really use the following, even though it doesn't cause the 
> warning (but would be messy if the user didn't have the package).
> 
> if(library(maps)) {
>   ...
> 
> If I try:
> 
> if(library(maps,logical.return=TRUE)) {
>   ...
> 
> I get the same warning as with "require". Does this qualify as a bug in 
> require/library or should I just not bother to test the result of 
> "library" and let the user suffer?
> 
> Jim
> 
> ______________________________________________
> 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