Skip to contents

purl() builds a Package URL (purl) for an R package. cran_doi() builds the DataCite DOI that CRAN assigns to each package.

Usage

purl(
  name,
  version = NA,
  source = "cran",
  namespace = NULL,
  repository_url = NULL
)

cran_doi(pkg)

Arguments

name

Package names, as a character vector.

version

Package versions, as a character vector. NA or "" omits the version.

source

Where the package comes from: "cran", "github", "gitlab" or "bitbucket".

namespace

Owner of the source repository. Required when source is "github", "gitlab" or "bitbucket".

repository_url

Optional repository URL, written unencoded as a repository_url qualifier. Use this for packages from repositories other than CRAN, such as Bioconductor, or from a GitHub Enterprise or GitLab server of one's own.

pkg

Package names, as a character vector.

Value

A character vector. purl() recycles name, version, namespace and repository_url to a common length: each must have length 1 or the length of the longest, otherwise it is an error.

Details

Unknown values give NA_character_ for that element. A package name that is NA or "", or a namespace that is NA or "", is unknown. Other elements of the vector are unaffected. A version that is NA or "" is left out of the purl.

Examples

purl("dplyr", "1.2.1")
#> [1] "pkg:cran/dplyr@1.2.1"
purl("srcpkg", "abc123", source = "github", namespace = "example")
#> [1] "pkg:github/example/srcpkg@abc123"
cran_doi("dplyr")
#> [1] "10.32614/CRAN.package.dplyr"