From 85e97f4a04582b7b26316e1d63cef882958f9340 Mon Sep 17 00:00:00 2001 From: Sanne Govaert <44606923+sannegovaert@users.noreply.github.com> Date: Tue, 27 Aug 2024 14:05:37 +0200 Subject: [PATCH] add param version --- R/example_package.R | 15 ++++++++++++--- man/example_package.Rd | 6 +++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/R/example_package.R b/R/example_package.R index a42bbe91..ab7b0a7d 100644 --- a/R/example_package.R +++ b/R/example_package.R @@ -9,14 +9,23 @@ #' `"path": ["observations_1.tsv", "observations_2.tsv"]`. #' 3. `media`: inline data stored in `data`. #' +#' @param version Version of the [Data Package]( +#' https://datapackage.org/blog/2024-06-26-v2-release/) standard that this +#' example Data Package uses. Currently only version 1 is supported. #' @return A Data Package object, see [create_package()]. #' @family sample data #' @export #' @examples #' example_package() -example_package <- function() { - path <- system.file( - "extdata", "v1", "datapackage.json", package = "frictionless" +example_package <- function(version = 1) { + if (!version %in% c(1, "1", 1.0, "1.0")) { + cli::cli_abort( + "Currently only version 1 is supported." ) + } else { + path <- system.file( + "extdata", "v1", "datapackage.json", package = "frictionless" + ) + } read_package(path) } diff --git a/man/example_package.Rd b/man/example_package.Rd index e3bf98b9..b961b81c 100644 --- a/man/example_package.Rd +++ b/man/example_package.Rd @@ -4,7 +4,11 @@ \alias{example_package} \title{Read the example Data Package} \usage{ -example_package() +example_package(version = 1) +} +\arguments{ +\item{version}{Version of the \href{https://datapackage.org/blog/2024-06-26-v2-release/}{Data Package} standard that this +example Data Package uses. Currently only version 1 is supported.} } \value{ A Data Package object, see \code{\link[=create_package]{create_package()}}.