Add-on packages

TODO

  • link to workspace for search()

Install required packages

coin, remotes

Error in install.packages(wants[!has]): unable to install packages

Useful online resources

  • Comprehensive R Archive Network (CRAN): These mirror servers are the primary hosts for contributed R add-on packages
  • r-pkg.org: Search and browse CRAN packages with a nicer user interface
  • CRAN Task Views: An organized and maintained list of packages useful for a specific data analysis task (e.g., multivariate statistics or psychometric models)
  • BioConductor: A host for add-on packages especially useful for genomic data analysis
  • rdrr.io: Search R related content - packages / help files

Install and update add-on packages

Information about installed packages

[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"      
[3] "/usr/lib/R/library"           
[1] "/usr/local/lib/R/site-library/coin"

Show first 10 of all installed packages

 [1] "abind"      "AICcmodavg" "askpass"    "assertthat" "backports" 
 [6] "base64enc"  "bayestestR" "beeswarm"   "BH"         "bit"       

Install and remove add-on packages

Install from CRAN

Install from GitHub repository (note: no quality control)

Information provided by add-on packages

Use add-on packages

Load add-on package

library() throws an error if the package cannot be found, unless option logical.return=TRUE is set.

Get a return value TRUE or FALSE that indicates whether package could be loaded

[1] FALSE

Know which packages are currently loaded

R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
 [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
 [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
[10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] coin_1.3-1     survival_3.2-7 stringr_1.4.0  knitr_1.30    

loaded via a namespace (and not attached):
 [1] codetools_0.2-16   lattice_0.20-41    matrixStats_0.57.0 mvtnorm_1.1-1     
 [5] zoo_1.8-8          MASS_7.3-51.5      grid_3.6.3         stats4_3.6.3      
 [9] magrittr_2.0.1     evaluate_0.14      stringi_1.5.3      multcomp_1.4-15   
[13] Matrix_1.2-18      sandwich_3.0-0     TH.data_1.0-10     splines_3.6.3     
[17] tools_3.6.3        xfun_0.19          parallel_3.6.3     compiler_3.6.3    
[21] libcoin_1.0-6      modeltools_0.2-23 
 [1] ".GlobalEnv"        "package:coin"      "package:survival" 
 [4] "package:stringr"   "package:knitr"     "package:stats"    
 [7] "package:graphics"  "package:grDevices" "package:utils"    
[10] "package:datasets"  "package:methods"   "Autoloads"        
[13] "package:base"     

Is one package masking functions from a different package?

If different packages provide functions with the same name, the function from the package loaded later masks the function from the package loaded earlier. Check if this happened:

$.GlobalEnv
[1] "args"

$`package:coin`
[1] "confint"    "initialize" "show"      

$`package:stats`
[1] "confint"

$`package:methods`
[1] "initialize" "show"       "body<-"     "kronecker" 

$`package:base`
[1] "args"      "body<-"    "kronecker"

Prevent masking - make conflicts an error when running library()

Explicitly state which package a function should be taken from.

[1] 2.666667

Un-load a package

Data sets from add-on packages

Detach (automatically) loaded packages (if possible)

Error in detach(package:remotes) : invalid 'name' argument

Get the article source from GitHub

R markdown - markdown - R code - all posts