Question: update all/some/none how to set default to "update all"
0
gravatar for rgiannico
4 months ago by
rgiannico10
rgiannico10 wrote:

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 • 168 views
ADD COMMENTlink modified 4 months ago by Fischer-philipp20 • written 4 months ago by rgiannico10
Answer: update all/some/none how to set default to "update all"
1
gravatar for rgiannico
4 months ago by
rgiannico10
rgiannico10 wrote:

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 COMMENTlink modified 4 months ago • written 4 months ago by rgiannico10
Answer: update all/some/none how to set default to "update all"
0
gravatar for Fischer-philipp
4 months ago by
Fischer-philipp20 wrote:

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 COMMENTlink modified 4 months ago • written 4 months ago by Fischer-philipp20

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

ADD REPLYlink written 4 months ago by rgiannico10
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 247 users visited in the last hour