Skip to contents

Attempt to install missing packages from CRAN.

Usage

install_missing_pkgs(pkgs_availability)

Arguments

pkgs_availability

Named logical vector where names are packages -- generally the output of running check_pkgs_availability().

Value

Installs packages from cran using remotes::install_cran() if available else install.packages()

Details

In most cases, is probably safer to clone and use renv::dependencies() -- README.

Examples

# should verify pkgs are available on CRAN -- example below wouldn't work #
# because madeUpPkg doesn't exist on CRAN
if (FALSE) {
library(funspotr)
library(dplyr)

file_lines <- "
library(dplyr)
require(tidyr)
library(madeUpPkg)

as_tibble(mpg) %>%
  group_by(class) %>%
  nest() %>%
  mutate(stats = purrr::map(data,
                            ~lm(cty ~ hwy, data = .x)))

made_up_fun()
"

file_output <- tempfile(fileext = '.R')
writeLines(file_lines, file_output)

spot_pkgs(file_output) %>%
  check_pkgs_availability() %>%
  funspotr:::install_missing_pkgs()
}