[R] how to check if a library is loaded, from a function
David Winsemius
dwinsemius at comcast.net
Tue Feb 1 05:49:49 CET 2011
On Jan 31, 2011, at 11:04 PM, Nick Matzke wrote:
> Hi,
>
> I've written a function which I load with a source command. The
> function requires a certain library, phangorn, to work.
>
> I would like the function to check if phangorn is loaded as a
> library before running. For some reason, just putting
> require(phangorn) into the sourced function doesn't do anything.
If a package is already loaded then require() will not load it again.
I think it is also going to be quiet if it's called in a sourced
routine, so I would ask whether you have properly tested your claim
that it "doesn't do anything"? If you start with a clean session and
source your routine, does the routine fail because the package does
not load?
>
> This must be simple, but I can't figure it out! Any help
> appreciated...
>
> --
> ====================================================
> Nicholas J. Matzke
> Ph.D. Candidate, Graduate Student Researcher
30 line sig elided.
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list