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

______________________________________________
R-help@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.

Reply via email to