update all/some/none how to set default to "update all"
2
0
Entering edit mode
rgiannico ▴ 10
@rgiannico-19913
Last seen 5.8 years ago

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?

source("http://bioconductor.org/biocLite.R") 
biocLite("Biostrings") 
[...] 
Update all/some/none? [a/s/n]:
biocLite update all default ask • 2.4k views
ADD COMMENT
1
Entering edit mode
rgiannico ▴ 10
@rgiannico-19913
Last seen 5.8 years ago

You can use either the ask=FALSE or ask="a" parameter.

biocLite("Biostrings", ask=FALSE)
biocLite("Biostrings", ask="a")

From the manual ?biocLite:

 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.

.

ADD COMMENT
0
Entering edit mode
@fischer-philipp-18490
Last seen 2.5 years ago
Austria

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
}
ADD COMMENT
0
Entering edit mode

nice tip! just a typo fix: in the first line of your answer you wrote "packman" instead of "pacman" ;)

ADD REPLY

Login before adding your answer.

Traffic: 541 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6