[R] Using require() vs. library()
Uwe Ligges
ligges at statistik.tu-dortmund.de
Wed Aug 17 20:13:53 CEST 2011
Actually require() is a wrapper around library() with more error
handling to be used inside other functions. Just type require(), you can
read the few lines of code quickly.
Uwe Ligges
On 17.08.2011 19:57, Nordlund, Dan (DSHS/RDA) wrote:
>> -----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
>
>
> ______________________________________________
> 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.
More information about the R-help
mailing list