Hello,

> pack <- "utils"
> help( write.table, package = pack )
Error in .find.package(package, lib.loc, verbose = verbose) :
  there is no package called 'pack'

Replacing this :

if(!missing(package))
        if(is.name(y <- substitute(package)))
            package <- as.character(y)


by this :

if( !missing(package) ){
                ischar <- tryCatch(is.character(package) && length(package) == 
1L,
                           error = identity)
        if(inherits(ischar, "error")) ischar <- FALSE
        
        ## if this was not a length-one character vector, try for the name.
        if(!ischar) {
                spackage <- deparse(substitute(package))
            if(!is.name(substitute(package)) )
stop("'package' should be a name or a length-one character vector")
            package <- spackage
        }
    }


makes these three calls work:

> help( write.table, package = "utils" )
> help( write.table, package = utils )
> help( write.table, package = pack )

... unless utils is a variable

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/BcPw : celebrating R commit #50000
|- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc
`- http://tr.im/yw8E : New R package : sos

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to