banner



How To Instal A Package In R

Installing R Packages

Jeffrey Leek
Johns Hopkins Bloomberg Schoolhouse of Public Wellness

R Packages

  • When you download R from the Comprehensive R Archive Network (CRAN), you get that ``base" R system

  • The base R system comes with basic functionality; implements the R language

  • I reason R is so useful is the big drove of packages that extend the basic functionality of R

  • R packages are developed and published past the larger R community

Obtaining R Packages

  • The primary location for obtaining R packages is CRAN

  • For biological applications, many packages are bachelor from the Bioconductor Projection

  • Yous can obtain information near the available packages on CRAN with the available.packages() function

              a <- available.packages() head(rownames(a), 3)  ## Show the names of the first few packages                          
              ## [1] "A3"       "abc"      "abcdeFBA"                          
  • There are approximately 5200 packages on CRAN covering a wide range of topics

  • A listing of some topics is available through the Task Views link, which groups together many R packages related to a given topic

Installing an R Parcel

  • Packages can be installed with the install.packages() part in R

  • To install a single package, laissez passer the proper name of the lecture to the install.packages() office every bit the first argument

  • The following the code installs the slidify package from CRAN

              install.packages("slidify")                          
  • This command downloads the slidify bundle from CRAN and installs it on your computer

  • Whatsoever packages on which this package depends volition also exist downloaded and installed

Installing an R Package

  • You can install multiple R packages at once with a single phone call to install.packages()

  • Place the names of the R packages in a grapheme vector

              install.packages(c("slidify", "ggplot2", "devtools"))                          

Installing an R Bundle in RStudio

Installing an R Package in RStudio

Installing an R Package from Bioconductor

  • To go the basic installer and basic ready of R packages (alert, will install multiple packages)
              source("http://bioconductor.org/biocLite.R") biocLite()                          
  • Identify the names of the R packages in a character vector
              biocLite(c("GenomicFeatures", "AnnotationDbi"))                          

http://www.bioconductor.org/install/

Loading R Packages

  • Installing a package does not brand it immediately bachelor to you in R; you must load the bundle

  • The library() function is used to load packages into R

  • The following code is used to load the ggplot2 packet into R

              library(ggplot2)                          
  • Whatever packages that demand to exist loaded as dependencies will be loaded outset, before the named package is loaded

  • Notation: Practice not put the package proper name in quotes!

  • Some packages produce messages when they are loaded (merely some don't)

Loading R Packages

After loading a bundle, the functions exported by that package will be attached to the elevation of the search() list (after the workspace)

              library(ggplot2) search()                          
              ##  [i] ".GlobalEnv"         "package:kernlab"    "package:caret"      ##  [4] "parcel:lattice"    "parcel:ggplot2"    "packet:makeslides" ##  [7] "bundle:knitr"      "package:slidify"    "tools:rstudio"      ## [10] "package:stats"      "parcel:graphics"   "bundle:grDevices"  ## [13] "package:utils"      "parcel:datasets"   "package:methods"    ## [16] "Autoloads"          "bundle:base"                          

Summary

  • R packages provide a powerful mechanism for extending the functionality of R

  • R packages tin can be obtained from CRAN or other repositories

  • The install.packages() tin exist used to install packages at the R console

  • The library() function loads packages that accept been installed so that you may access the functionality in the package

Source: https://jtleek.com/modules/01_DataScientistToolbox/02_09_installingRPackages/

Posted by: stoltzfusupoinfor72.blogspot.com

0 Response to "How To Instal A Package In R"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel