Reputation: 133
I have looked at the install.packages help files, Google, and Stack, but I don't see a way to prompt the user prior to installing a package. Is there an install.packages option to require a user prompt asking if the user wants to install the package prior to actually installing the package?
In not possible using install.packages, is there another way to achieve this result?
Upvotes: 2
Views: 609
Reputation: 1888
You can use function menu() inside an if statement to make a simple confirmation mechanism. This will work:
package <- "foo"
if (menu(c("Yes", "No"),
title= paste("Are you sure you want to install package", package)) == "1") {
install.packages(package)
} else { print("Cancelling installation")}
Upvotes: 2