Skip to content

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

@SermetPekin

Description

@SermetPekin

Thanks for creating and maintaining this package.

I was thinking it would be super handy if Require() could accept a plain multi-line string instead of 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:

Require(parse_packages("
# ...........................................
# Requirements 
# ...........................................
  dplyr
  lme4
  # ggplot2
  PredictiveEcology/LandR@development
"))

Would it make sense to support this natively in Require(), 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