[R] Using require() vs. library()
Nordlund, Dan (DSHS/RDA)
NordlDJ at dshs.wa.gov
Wed Aug 17 19:57:20 CEST 2011
> -----Original Message-----
> From: istazahn at gmail.com [mailto:istazahn at gmail.com] On Behalf Of Ista
> Zahn
> Sent: Wednesday, August 17, 2011 10:12 AM
> To: Nordlund, Dan (DSHS/RDA)
> Cc: r-help at r-project.org
> Subject: Re: [R] Using require() vs. library()
>
> Hi Dan,
> Is there something you would like to know that is not covered by
> help(library) ?
>
> Best,
> Ista
>
> On Wed, Aug 17, 2011 at 12:40 PM, Nordlund, Dan (DSHS/RDA)
> <NordlDJ at dshs.wa.gov> wrote:
> > A recent post prompts me to ask this question. Is there any reason
> to prefer using library() over require()? I tend to use require()
> instead of library() to load packages, but I wonder if there are
> situations where it would be better to use library().
>
Well, I guess when I read that "require is designed for use inside other functions..." I wasn't sure if that meant there might be times when it would be better to use library when not inside other functions. But maybe it was more generally a question about style, prompted by a post responding to the common confusion between the terms 'package' and 'library' amongst those new to R. To me, it always seemed more natural type require(my.package) than library(my.package). I just wanted to make sure I wasn't missing something that might make me regret that choice.
Dan
Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
More information about the R-help
mailing list