Konrad
Konrad

Reputation: 18585

Installing packages that have a common string in a loop

I've recently came across Deducer, it crossed my mind to have a look at it and I progressed to installing the package. After searching through CRAN it occurred to me that there is a number of packages that support Deducer:

packs

Instead of running:

install.packages("Deducer")
install.packages("DeducerExtras")

I would prefer to run a loop for all the packages that have Deducer string in the name. Hence my question, how can I get list of packages from CRAN where name matches specific string and install them in a loop?

Upvotes: 1

Views: 175

Answers (1)

user3710546
user3710546

Reputation:

Quite raw:

out <- available.packages()
libs <- as.vector(out[grep("Deducer", out[,1]),1])
lapply(libs, install.packages)

Upvotes: 3

Related Questions