Message-ID: <806322fe0911021206n356e658ao3434857b1359d1a0@mail.gmail.com>
Date: 2009-11-02T20:06:28Z
From: Charlie Sharpsteen
Subject: "Safe" way to automatically install required packages...
In-Reply-To: <4AEF2B59.3050809@ucdavis.edu>
On Mon, Nov 2, 2009 at 10:56 AM, 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
Place the dependencies of your package in a comma-seperated list in the
depends:
field of the DESCRIPTION file. When a user runs install.packages(
'yourPackage', dependencies = T ), R will take care of downloading and
installing the dependencies
-Charlie