Skip to content

Feature Request: Allow passing a multi-line string of packages to pak::pak() #855

@SermetPekin

Description

@SermetPekin

Hi @gaborcsardi

I was thinking it would be super handy if pak::pak() could also accept a plain multi-line string (in addition to a character vector with lots of quotes and commas). It makes copy-pasting and managing large lists of dependencies much easier.

Ideally, the function would ignore blank lines, trim spaces, and let us use # to comment out specific packages.

Here's a quick helper function I wrote to show what I mean:

parse_packages <- function(text) {
  pkgs <- unlist(strsplit(text, "\n"))
  pkgs <- trimws(pkgs)
  pkgs <- pkgs[!grepl("^#", pkgs)]
  pkgs <- pkgs[pkgs != ""]
  return(pkgs)
}

Usage:

pak::pak(parse_packages("
# ...........................................
# Requirements 
# ...........................................
  dplyr
  lme4
  # ggplot2
  tidyverse/tibble
  
"))

Would it make sense to support this natively in pak(), or include a small helper function like this to do the heavy lifting?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions