Size: 916
Comment:
|
← Revision 4 as of 2023-11-28 04:45:35 ⇥
Size: 2261
Comment: Thorough rewrite
|
Deletions are marked like this. | Additions are marked like this. |
Line 3: | Line 3: |
R packages are installed by the R interpretter itself. | The main strength of R is the ecosystem of '''R packages'''. In many instances, users are recommended to install packages within an R REPL. For [[Linux]] users, it is possible to use the system package manager instead. |
Line 14: | Line 16: |
# To install, try... | # To install |
Line 17: | Line 19: |
# If download and compilation succeeded, try loading the package. | # To update update.packages() # To then use |
Line 25: | Line 30: |
== Install from Source Code == | == Alternative Interactive Installations == === Install from Source Code === To install from source code, thereby compiling any binaries as necessary, try: |
Line 31: | Line 42: |
---- | |
Line 34: | Line 44: |
=== Install from GitHub === | |
Line 35: | Line 46: |
== Install from GitHub == | There are several R packages that exist as toolchains for installing other packages directly from !GitHub. |
Line 37: | Line 48: |
Multiple packages exist for installing packages directly from !GitHub. | As an example, the `devtools` package: {{{ install.packages("devtools") |
Line 39: | Line 52: |
Once the `devtools` package has been downloaded, try using the `install_github` function. {{{ |
|
Line 45: | Line 55: |
Alternatively, once the `pak` package has been downloaded, try using the `pak` function. | As another example, the `pak` package: |
Line 48: | Line 58: |
install.packages("pak", repos=sprintf("https://r-lib.github.io/p/pak/stable/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch)) |
|
Line 54: | Line 66: |
== System Package Managers == | |
Line 55: | Line 68: |
== Updating Packages == | === Ubuntu === Follow the instructions at [[https://cran.r-project.org/bin/linux/ubuntu/]]. Namely: |
Line 58: | Line 75: |
update.packages() | # minimal requirements sudo apt install --no-install-recommends software-properties-common dirmngr # add the PPA signing key # Fingerprint: E298A3A825C0D65DFD57CBB651716619E084DAB9 wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc # add the PPA sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" # install R sudo apt install --no-install-recommends r-base # install R packages sudo apt install --no-install-recommends r-cran-tidyverse |
Line 60: | Line 91: |
=== Arch === While some R packages have corresponding AUR PKGBUILDS, they are generally poor quality. Instead either follow the instructions at [[https://github.com/dvdesolve/ArchRPkgs#binary-repository]] or use that repository's PKGBUILDs to build the R packages directly. |
Installing R Packages
The main strength of R is the ecosystem of R packages.
In many instances, users are recommended to install packages within an R REPL. For Linux users, it is possible to use the system package manager instead.
Contents
Example
# To install install.packages("tidyverse") # To update update.packages() # To then use library(tidyverse)
Alternative Interactive Installations
Install from Source Code
To install from source code, thereby compiling any binaries as necessary, try:
install.packages("path/to/tidyverse_2.0.0.tar.gz", repos=NULL)
Install from GitHub
There are several R packages that exist as toolchains for installing other packages directly from !GitHub.
As an example, the devtools package:
install.packages("devtools") devtools::install_github("tidyverse/ggplot2")
As another example, the pak package:
install.packages("pak", repos=sprintf("https://r-lib.github.io/p/pak/stable/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch)) pak::pak("tidyverse/ggplot2")
System Package Managers
Ubuntu
Follow the instructions at https://cran.r-project.org/bin/linux/ubuntu/. Namely:
# minimal requirements sudo apt install --no-install-recommends software-properties-common dirmngr # add the PPA signing key # Fingerprint: E298A3A825C0D65DFD57CBB651716619E084DAB9 wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc # add the PPA sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" # install R sudo apt install --no-install-recommends r-base # install R packages sudo apt install --no-install-recommends r-cran-tidyverse
Arch
While some R packages have corresponding AUR PKGBUILDS, they are generally poor quality. Instead either follow the instructions at https://github.com/dvdesolve/ArchRPkgs#binary-repository or use that repository's PKGBUILDs to build the R packages directly.