[R] How can I check a package is installed or not?
murdoch.duncan at gmail.com
Tue Sep 27 22:13:32 CEST 2011
On 11-09-27 3:19 PM, Fabrice Tourre wrote:
> Dear list,
> How can I detect a package is installed or not? If not, then install it.
Here's one way. This might be slow if you have all of CRAN installed,
but it's quick enough if you only have a few dozen packages:
installed <- rownames(installed.packages())
"DESeq" %in% installed
Another way is to use
if (!require("DESeq")) ...
but that will give warnings if DESeq is not there.
> For example, in a script, I want to check the package DESeq is
> installed or not. If not, then I will using this script to install it.
> The pseudo script would be like this:
> Thank you
> R-help at r-project.org mailing list
> 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