Skip to contents

A unified installer for R packages from CRAN, GitHub, Bioconductor, or local source.

Usage

inst_pkg(
  pkg = NULL,
  source = c("CRAN", "GitHub", "Bioconductor", "local"),
  path = NULL,
  ...
)

Arguments

pkg

Package name(s) or GitHub repo (e.g., "user/repo"). Not required for source = "local".

source

Source of package: "CRAN", "GitHub", "Bioconductor", "local". Case-insensitive, shorthand allowed.

path

Path to local package file (used when source = "local").

...

Additional arguments passed to install.packages(), devtools::install_github(), or BiocManager::install().

Value

NULL (invisibly)

Examples

inst_pkg("dplyr", source = "cran")
#> ✅ Package [dplyr] is already installed. Skipped.
inst_pkg("hadley/emo", source = "gh")
#> 🔽 Installing from GitHub: [hadley/emo]
#> Using GitHub PAT from the git credential store.
#> Downloading GitHub repo hadley/emo@HEAD
#> cli (3.6.4 -> 3.6.5) [CRAN]
#> Installing 1 packages: cli
#> Installing package into 'C:/Users/84241/AppData/Local/Temp/RtmpwXiO5u/temp_libpath9fe4719d7997'
#> (as 'lib' is unspecified)
#> 
#>   There is a binary version available but the source version is later:
#>     binary source needs_compilation
#> cli  3.6.4  3.6.5              TRUE
#> 
#> installing the source package 'cli'
#> ── R CMD build ─────────────────────────────────────────────────────────────────
#> * checking for file 'C:\Users\84241\AppData\Local\Temp\Rtmpiya7Z6\remotes183071717524\hadley-emo-3f03b11/DESCRIPTION' ... OK

#> * preparing 'emo':

#> * checking DESCRIPTION meta-information ... OK

#> * checking for LF line-endings in source and make files and shell scripts

#> * checking for empty or unneeded directories

#> * building 'emo_0.0.0.9000.tar.gz'

#> 

#> Installing package into 'C:/Users/84241/AppData/Local/Temp/RtmpwXiO5u/temp_libpath9fe4719d7997'
#> (as 'lib' is unspecified)
#> 🎉 Installation complete!
inst_pkg("scRNAseq", source = "bio")
#> ✅ Package [scRNAseq] is already installed. Skipped.
inst_pkg(source = "local", path = "mypackage.tar.gz")
#> 📂 Installing from local path: [mypackage.tar.gz]
#> Installing package into 'C:/Users/84241/AppData/Local/Temp/RtmpwXiO5u/temp_libpath9fe4719d7997'
#> (as 'lib' is unspecified)
#> Warning: installation of package 'mypackage.tar.gz' had non-zero exit status
#> 🎉 Installation complete!