I would like to install a bioconductor package (for example Biostrings) using biocLite,
but R keep asking me if I want to update some other packeges.
How can I force the answer to be always "update all" without having to answer?
ask: ‘logical(1)’ indicating whether to prompt user before
installed packages are updated, or the character string
'graphics', which brings up a widget for choosing which
packages to update. If TRUE, user can choose whether to
update all outdated packages without further prompting, to
pick and choose packages to update, or to cancel updating (in
a non-interactive session, no packages will be updated).
Otherwise, the value is passed to ‘update.packages’.
This means ask can be a nonlogical value, you can use it to set the answer you want to pass to the update.packages function.
There is a way using the package pacman.and its function p_load.
This should to what you want.
p_load("Biostrings")
The following code is usefull if you have to run lots of packages.
load.libs <- c("Biostrings") #and some more packages
if (!require("pacman")) install.packages("pacman");
library(pacman)
p_load(load.libs, update = TRUE, character.only = TRUE)
status <- sapply(load.libs, require, character.only = TRUE)
if(all(status)){
print("SUCCESS: You have successfully installed and loaded all required libraries.")
} else{
cat("ERROR: One or more libraries failed to install correctly. Check the following list for FALSE cases and try again...\n\n")
status
}
nice tip! just a typo fix: in the first line of your answer you wrote "packman" instead of "pacman" ;)