help

Aurelien Chateigner

2018年11月05日

Introduction

This vignette exists as help is limited by CRAN to 5 seconds runs, and it depends a lot on user’s connection. It will also explain the advance use of the package.

Using anyLib

Loading the package

To load anyLib, simply :

library(anyLib)

For the purpose of the demonstration, installations in this vignette are done in a dummy library:

lib <-normalizePath(tempdir(), "/")
f1 <-paste(lib, "folder1", sep = "/")
dir.create(f1)
.libPaths(f1)

Install and load 1 package

CRAN package

So, if one wants to install a simple CRAN package and load it, simply:

anyLib("apercu", lib = f1)
#> also installing the dependencies 'assertthat', 'cli', 'crayon', 'digest', 'magrittr', 'praise', 'R6', 'rlang', 'withr', 'pls', 'testthat'
#> package 'assertthat' correctement décompressé et sommes MD5 vérifiées
#> package 'cli' correctement décompressé et sommes MD5 vérifiées
#> package 'crayon' correctement décompressé et sommes MD5 vérifiées
#> package 'digest' correctement décompressé et sommes MD5 vérifiées
#> package 'magrittr' correctement décompressé et sommes MD5 vérifiées
#> package 'praise' correctement décompressé et sommes MD5 vérifiées
#> package 'R6' correctement décompressé et sommes MD5 vérifiées
#> package 'rlang' correctement décompressé et sommes MD5 vérifiées
#> package 'withr' correctement décompressé et sommes MD5 vérifiées
#> package 'pls' correctement décompressé et sommes MD5 vérifiées
#> package 'testthat' correctement décompressé et sommes MD5 vérifiées
#> package 'apercu' correctement décompressé et sommes MD5 vérifiées
#> 
#> The downloaded binary packages are in
#> C:\Users\achateigner\AppData\Local\Temp\RtmpshD88Y\downloaded_packages
#> Loading required package: apercu
#> apercu 
#> TRUE

Source package

For a source package:

anyLib(system.file("dummyPackage_0.1.0.tar.gz", package = "anyLib"),
 source = TRUE, lib = f1, loadLib = f1)
#> Loading required package: dummyPackage
#> dummyPackage 
#> TRUE

Bioconductor package

For a Bioconductor package:

anyLib("limma", lib = f1, loadLib = f1)
#> Loading required package: limma
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'limma'
#> limma 
#> FALSE

github package

And for github, to install, one needs the name in the format "maintainerName/packageName":

anyLib("achateigner/dummyPackage", force = TRUE, lib = f1, loadLib = f1)
#> dummyPackage 
#> TRUE

But to load it once installed, one only needs its name:

anyLib("dummyPackage", lib = f1, loadLib = f1)
#> dummyPackage 
#> TRUE

Install and load a list of packages

To install and load a list of packages, from various places, with the names. I install them in a different folder:

f2 <-paste(lib, "folder2", sep = "/")
dir.create(f2)
anyLib(list("apercu", "limma", "achateigner/dummyPackage"), lib = f2,
 loadLib = f2)
#> package 'apercu' correctement décompressé et sommes MD5 vérifiées
#> 
#> The downloaded binary packages are in
#> C:\Users\achateigner\AppData\Local\Temp\RtmpshD88Y\downloaded_packages
#> Loading required package: apercu
#> Loading required package: limma
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'limma'
#> Loading required package: dummyPackage
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'dummyPackage'
#> apercu limma dummyPackage 
#> TRUE FALSE FALSE

To install and load from a list of packages in an object:

f3 <-paste(lib, "folder3", sep = "/")
dir.create(f3)
packagesNeeded <-list("apercu", "limma", "achateigner/dummyPackage")
anyLib(packagesNeeded, lib = f3, loadLib = f3)
#> package 'apercu' correctement décompressé et sommes MD5 vérifiées
#> 
#> The downloaded binary packages are in
#> C:\Users\achateigner\AppData\Local\Temp\RtmpshD88Y\downloaded_packages
#> Loading required package: apercu
#> Loading required package: limma
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'limma'
#> Loading required package: dummyPackage
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'dummyPackage'
#> apercu limma dummyPackage 
#> TRUE FALSE FALSE

Advanced options

If one wants to reinstall a package or force the update (force = TRUE), not update the Bioconductor packages (autoUpdate = FALSE), install in a different lib and load from a set of libs:

f4 <-paste(lib, "folder4", sep = "/")
dir.create(f4)
anyLib(packagesNeeded,
 force = TRUE,
 autoUpdate = FALSE,
 lib = f4,
 loadLib = c(f1, f4))
#> package 'apercu' correctement décompressé et sommes MD5 vérifiées
#> 
#> The downloaded binary packages are in
#> C:\Users\achateigner\AppData\Local\Temp\RtmpshD88Y\downloaded_packages
#> Loading required package: apercu
#> Loading required package: limma
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'limma'
#> Loading required package: dummyPackage
#> apercu limma dummyPackage 
#> TRUE FALSE TRUE

AltStyle によって変換されたページ (->オリジナル) /