[R] "Safe" way to automatically install required packages...

hadley wickham h.wickham at gmail.com
Mon Nov 2 20:02:02 CET 2009


If you package "depends" on another package, it will be automatically installed.

Hadley

On Mon, Nov 2, 2009 at 12:56 PM, Jonathan Greenberg
<greenberg at ucdavis.edu> wrote:
> R-helpers:
>
>   I'm working on an r-package that I want to make as easy-to-use as possible
> for a novice R-user, which includes automatically installing required
> packages.   I, myself, am a novice R-packager, so the solution I came up
> with was to embed:
>
> print("Loading required packages...")
> if (!require("reshape")) { install.packages("reshape") }
> if (!require("reshape")) {
>   print("Could not install package 'reshape', please contact your
> sysadmin.")
>   return()
> }
>
>   in the code proper, and put together the package using package.skeleton()
> and R CMD build.
>
>   I'm guessing there's a better way to do this -- any suggestions?
> --j
>
> --
>
> Jonathan A. Greenberg, PhD
> Postdoctoral Scholar
> Center for Spatial Technologies and Remote Sensing (CSTARS)
> University of California, Davis
> One Shields Avenue
> The Barn, Room 250N
> Davis, CA 95616
> Phone: 415-763-5476
> AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307
>
> ______________________________________________
> 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.
>



-- 
http://had.co.nz/




More information about the R-help mailing list