On 25 August 2010 at 08:06, Prof Brian Ripley wrote: | On Tue, 24 Aug 2010, Dirk Eddelbuettel wrote: | | > | > On 24 August 2010 at 15:40, Hadley Wickham wrote: | > | Hi all, | > | | > | If a package suggests another package in its description, you can | > | check it at runtime with requires. How do you do check if a package | > | is available without loading it, if you only want to access one | > | function in the package namespace. | > | > I needed this a few days ago for a small package and resorted to this: | > | > .packages <- as.character(installed.packages()[,1]) | > | > [...] | > | > hasGputools <- function() { | > any( "gputools" == .packages ) | > } | > | > That way I get around Depends, Suggests and other thing that may impact the | > running of 'R CMD check' and friends. | | But thereby clobber your users with the run-time cost of | installed.packages() (which can take several minutes on some Windows
Yes. As that was for a so-far internal-only package that in all likelihood will never be built on Windows for limitations of the latter platform. Regardless, I will switch to Henrik's elegant alternative. | systems, and just took ca 12secs on my fastest Linux server with 3000 | packages installed). If you want to take this route (is a package | installed?), see the 'Note' on ?installed.packages for better | alternatives. My version of ?installed.packages has no section "Note". That is on the on the current, released version of R. Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel