diff --git a/.github/workflows/R-CMD-check-dev.yaml b/.github/workflows/R-CMD-check-dev.yaml index f7b75ac..4092fa8 100644 --- a/.github/workflows/R-CMD-check-dev.yaml +++ b/.github/workflows/R-CMD-check-dev.yaml @@ -12,7 +12,7 @@ name: R-CMD-check-dev jobs: R-CMD-check-dev: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: diff --git a/DESCRIPTION b/DESCRIPTION index 0a38d9b..b130c0e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -64,6 +64,6 @@ URL: https://iqss.github.io/dataverse-client-r/, https://dataverse.org/, https:/ BugReports: https://github.com/iqss/dataverse-client-r/issues VignetteBuilder: knitr Encoding: UTF-8 -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 Roxygen: list(markdown = TRUE) Config/testthat/edition: 3 diff --git a/NAMESPACE b/NAMESPACE index 01c64af..32d841a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,16 @@ # Generated by roxygen2: do not edit by hand +S3method(create_zip,character) +S3method(create_zip,data.frame) +S3method(create_zip,list) +S3method(dataset_id,character) +S3method(dataset_id,dataverse_dataset) +S3method(dataset_id,default) +S3method(dataverse_id,character) +S3method(dataverse_id,dataverse) +S3method(get_fileid,character) +S3method(get_fileid,dataverse_file) +S3method(get_fileid,numeric) S3method(print,dataset_atom) S3method(print,dataset_statement) S3method(print,dataverse) diff --git a/R/SWORD_files.R b/R/SWORD_files.R index d4fddfa..3b5fc8f 100644 --- a/R/SWORD_files.R +++ b/R/SWORD_files.R @@ -1,6 +1,7 @@ create_zip <- function(x, ...) { UseMethod("create_zip", x) } +#' @export create_zip.character <- function(x, ...) { f <- file.exists(x) if (any(!f)) { @@ -11,6 +12,7 @@ create_zip.character <- function(x, ...) { return(tmp) } } +#' @export create_zip.data.frame <- function(x, ...) { tmpdf <- tempfile(fileext = ".zip") on.exit(file.remove(tmpdf), add = TRUE) @@ -19,6 +21,7 @@ create_zip.data.frame <- function(x, ...) { stopifnot(!utils::zip(tmp, tmpdf)) return(tmp) } +#' @export create_zip.list <- function(x, ...) { tmpdf <- sapply(seq_along(x), tempfile(fileext = ".zip")) on.exit(file.remove(tmpdf), add = TRUE) diff --git a/R/dataverse-package.R b/R/dataverse-package.R index a703bc8..83ea3cf 100644 --- a/R/dataverse-package.R +++ b/R/dataverse-package.R @@ -1,4 +1,3 @@ -#' @docType package #' @name dataverse #' @title Client for Dataverse Repositories #' @description Provides access to Dataverse 4+ APIs, enabling data search, retrieval, and deposit. @@ -27,4 +26,4 @@ #' #' \href{https://dataverse.harvard.edu/}{Harvard IQSS Dataverse} #' -NULL +"_PACKAGE" diff --git a/R/print.R b/R/print.R index f514a1f..fa8b582 100644 --- a/R/print.R +++ b/R/print.R @@ -54,10 +54,17 @@ print.dataverse_dataset <- function(x, ...) { cat("Release Date: ", x$releaseTime, "\n", sep = "") } if ("license" %in% names(x)) { - cat("License: ", x$license, "\n", sep = "") + if (is.list(x$license)) { + ## Dataverse >= 5.10 + license <- x$license$name + } else { + ## legacy + license <- x$name + } + cat("License: ", license,"\n", sep = "") } if ("files" %in% names(x)) { - n <- length(x$files) + n <- NROW(x$files) cat(n, ngettext(n, " File:", " Files:"), "\n", sep = "") print(x$files[c("label", "version", "id", "contentType")]) } diff --git a/R/utils.R b/R/utils.R index eec77b6..27e613a 100644 --- a/R/utils.R +++ b/R/utils.R @@ -5,9 +5,11 @@ dataverse_id <- function(x, ...) { dataverse_id.default <- function(x, ...) { x } +#' @export dataverse_id.character <- function(x, ...) { get_dataverse(x, ..., check = FALSE)$id } +#' @export dataverse_id.dataverse <- function(x, ...) { x$id } @@ -16,9 +18,11 @@ dataverse_id.dataverse <- function(x, ...) { dataset_id <- function(x, ...) { UseMethod("dataset_id", x) } +#' @export dataset_id.default <- function(x, ...) { x } +#' @export dataset_id.character <- function(x, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) { x <- prepend_doi(x) u <- paste0(api_url(server), "datasets/:persistentId?persistentId=", x) @@ -28,6 +32,7 @@ dataset_id.character <- function(x, key = Sys.getenv("DATAVERSE_KEY"), server = }) jsonlite::fromJSON(httr::content(r, as = "text", encoding = "UTF-8"))[["data"]][["id"]] } +#' @export dataset_id.dataverse_dataset <- function(x, ...) { x$id } @@ -37,6 +42,7 @@ get_fileid <- function(x, ...) { UseMethod("get_fileid", x) } +#' @export get_fileid.numeric <- function(x, file, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) { files <- dataset_files(x, key = key, server = server, ...) ids <- unlist(lapply(files, function(x) x[["datafile"]][["id"]])) @@ -57,6 +63,7 @@ get_fileid.numeric <- function(x, file, key = Sys.getenv("DATAVERSE_KEY"), serve id } +#' @export get_fileid.character <- function(x, file, key = Sys.getenv("DATAVERSE_KEY"), server = Sys.getenv("DATAVERSE_SERVER"), ...) { files <- dataset_files(prepend_doi(x), key = key, server = server, ...) ids <- unlist(lapply(files, function(x) x[["dataFile"]][["id"]])) @@ -77,6 +84,7 @@ get_fileid.character <- function(x, file, key = Sys.getenv("DATAVERSE_KEY"), ser id } +#' @export get_fileid.dataverse_file <- function(x, ...) { x[["dataFile"]][["id"]] } diff --git a/man-roxygen/ds.R b/man-roxygen/ds.R index efe78d0..d65750b 100644 --- a/man-roxygen/ds.R +++ b/man-roxygen/ds.R @@ -1,3 +1,3 @@ #' @param dataset A character specifying a persistent identification ID for a dataset, -#' for example `"doi:10.70122/FK2/HXJVJU"`. Alternatively, an object of class +#' for example `"10.70122/FK2/HXJVJU"`. Alternatively, an object of class #' \dQuote{dataverse_dataset} obtained by `dataverse_contents()`. diff --git a/man-roxygen/envvars.R b/man-roxygen/envvars.R index 979701b..012f0ef 100644 --- a/man-roxygen/envvars.R +++ b/man-roxygen/envvars.R @@ -7,5 +7,5 @@ #' most major. The server can be defined each time within a function, or it can #' be set as a default via an environment variable. To set a default, run #' `Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")` -#' or add `DATAVERSE_SERVER = "dataverse.harvard.edu` in one's `.Renviron` +#' or add `DATAVERSE_SERVER = "dataverse.harvard.edu"` in one's `.Renviron` #' file (`usethis::edit_r_environ()`), with the appropriate domain as its value. diff --git a/man/URLs.Rd b/man/URLs.Rd index 822b272..aaa67d1 100644 --- a/man/URLs.Rd +++ b/man/URLs.Rd @@ -57,7 +57,7 @@ class \dQuote{dataverse_file} as returned by \code{\link{dataset_files}}. Can be a vector for multiple files.} \item{dataset}{A character specifying a persistent identification ID for a dataset, -for example \code{"doi:10.70122/FK2/HXJVJU"}. Alternatively, an object of class +for example \code{"10.70122/FK2/HXJVJU"}. Alternatively, an object of class \dQuote{dataverse_dataset} obtained by \code{dataverse_contents()}.} \item{format}{A character string specifying a file format for download. @@ -77,7 +77,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{original}{A logical, defaulting to TRUE. If a ingested (.tab) version is diff --git a/man/add_dataset_file.Rd b/man/add_dataset_file.Rd index 4e6e7f2..8e9fa05 100644 --- a/man/add_dataset_file.Rd +++ b/man/add_dataset_file.Rd @@ -29,7 +29,7 @@ update_dataset_file( \item{file}{A character string for the location path of the file to be uploaded.} \item{dataset}{A character specifying a persistent identification ID for a dataset, -for example \code{"doi:10.70122/FK2/HXJVJU"}. Alternatively, an object of class +for example \code{"10.70122/FK2/HXJVJU"}. Alternatively, an object of class \dQuote{dataverse_dataset} obtained by \code{dataverse_contents()}.} \item{description}{Optionally, a character string providing a description of the file.} @@ -44,7 +44,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/add_file.Rd b/man/add_file.Rd index 903b6a7..64e5670 100644 --- a/man/add_file.Rd +++ b/man/add_file.Rd @@ -27,7 +27,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/create_dataset.Rd b/man/create_dataset.Rd index 489c4aa..51510ab 100644 --- a/man/create_dataset.Rd +++ b/man/create_dataset.Rd @@ -36,7 +36,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as @@ -44,7 +44,7 @@ file (\code{usethis::edit_r_environ()}), with the appropriate domain as its valu \code{\link[httr]{DELETE}}.} \item{dataset}{A character specifying a persistent identification ID for a dataset, -for example \code{"doi:10.70122/FK2/HXJVJU"}. Alternatively, an object of class +for example \code{"10.70122/FK2/HXJVJU"}. Alternatively, an object of class \dQuote{dataverse_dataset} obtained by \code{dataverse_contents()}.} } \value{ diff --git a/man/create_dataverse.Rd b/man/create_dataverse.Rd index a215035..7b59cd9 100644 --- a/man/create_dataverse.Rd +++ b/man/create_dataverse.Rd @@ -24,7 +24,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/dataset_atom.Rd b/man/dataset_atom.Rd index 22631e8..605994a 100644 --- a/man/dataset_atom.Rd +++ b/man/dataset_atom.Rd @@ -32,7 +32,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/dataset_versions.Rd b/man/dataset_versions.Rd index efd4a3e..5cea74d 100644 --- a/man/dataset_versions.Rd +++ b/man/dataset_versions.Rd @@ -13,7 +13,7 @@ dataset_versions( } \arguments{ \item{dataset}{A character specifying a persistent identification ID for a dataset, -for example \code{"doi:10.70122/FK2/HXJVJU"}. Alternatively, an object of class +for example \code{"10.70122/FK2/HXJVJU"}. Alternatively, an object of class \dQuote{dataverse_dataset} obtained by \code{dataverse_contents()}.} \item{key}{A character string specifying a Dataverse server API key. If one @@ -26,7 +26,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/dataverse.Rd b/man/dataverse.Rd index ae96eae..a35185c 100644 --- a/man/dataverse.Rd +++ b/man/dataverse.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/dataverse-package.R \docType{package} \name{dataverse} +\alias{dataverse-package} \alias{dataverse} \title{Client for Dataverse Repositories} \description{ @@ -33,3 +34,32 @@ This package provides five main sets of functions to interact with Dataverse: \href{https://dataverse.harvard.edu/}{Harvard IQSS Dataverse} } +\seealso{ +Useful links: +\itemize{ + \item \url{https://iqss.github.io/dataverse-client-r/} + \item \url{https://dataverse.org/} + \item \url{https://github.com/iqss/dataverse-client-r} + \item Report bugs at \url{https://github.com/iqss/dataverse-client-r/issues} +} + +} +\author{ +\strong{Maintainer}: Shiro Kuriwaki \email{shirokuriwaki@gmail.com} (\href{https://orcid.org/0000-0002-5687-2647}{ORCID}) + +Authors: +\itemize{ + \item Will Beasley \email{wibeasley@hotmail.com} (\href{https://orcid.org/0000-0002-5613-5006}{ORCID}) + \item Thomas J. Leeper \email{thosjleeper@gmail.com} (\href{https://orcid.org/0000-0003-4097-6326}{ORCID}) + \item Philip Durbin \email{philipdurbin@gmail.com} (\href{https://orcid.org/0000-0002-9528-9470}{ORCID}) + \item Sebastian Karcher \email{karcher@u.northwestern.edu} (\href{https://orcid.org/0000-0001-8249-7388}{ORCID}) +} + +Other contributors: +\itemize{ + \item Jan Kanis [contributor] + \item Edward Jee [contributor] + \item Johannes Gruber \email{JohannesB.Gruber@gmail.com} (\href{https://orcid.org/0000-0001-9177-1772}{ORCID}) [contributor] +} + +} diff --git a/man/dataverse_metadata.Rd b/man/dataverse_metadata.Rd index edb5f5f..c6ae364 100644 --- a/man/dataverse_metadata.Rd +++ b/man/dataverse_metadata.Rd @@ -24,7 +24,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/dataverse_search.Rd b/man/dataverse_search.Rd index ba7ba77..e752331 100644 --- a/man/dataverse_search.Rd +++ b/man/dataverse_search.Rd @@ -52,7 +52,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{verbose}{A logical indicating whether to display information about the search query (default is \code{TRUE}).} diff --git a/man/delete_dataset.Rd b/man/delete_dataset.Rd index a9bbeec..c5ae98f 100644 --- a/man/delete_dataset.Rd +++ b/man/delete_dataset.Rd @@ -13,7 +13,7 @@ delete_dataset( } \arguments{ \item{dataset}{A character specifying a persistent identification ID for a dataset, -for example \code{"doi:10.70122/FK2/HXJVJU"}. Alternatively, an object of class +for example \code{"10.70122/FK2/HXJVJU"}. Alternatively, an object of class \dQuote{dataverse_dataset} obtained by \code{dataverse_contents()}.} \item{key}{A character string specifying a Dataverse server API key. If one @@ -26,7 +26,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/delete_dataverse.Rd b/man/delete_dataverse.Rd index 1992609..132c693 100644 --- a/man/delete_dataverse.Rd +++ b/man/delete_dataverse.Rd @@ -24,7 +24,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/delete_file.Rd b/man/delete_file.Rd index 364fc45..839bfcd 100644 --- a/man/delete_file.Rd +++ b/man/delete_file.Rd @@ -24,7 +24,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/delete_sword_dataset.Rd b/man/delete_sword_dataset.Rd index 04d9a39..da5eee2 100644 --- a/man/delete_sword_dataset.Rd +++ b/man/delete_sword_dataset.Rd @@ -24,7 +24,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/files.Rd b/man/files.Rd index 691ac3d..13741aa 100644 --- a/man/files.Rd +++ b/man/files.Rd @@ -65,7 +65,7 @@ class \dQuote{dataverse_file} as returned by \code{\link{dataset_files}}. Can be a vector for multiple files.} \item{dataset}{A character specifying a persistent identification ID for a dataset, -for example \code{"doi:10.70122/FK2/HXJVJU"}. Alternatively, an object of class +for example \code{"10.70122/FK2/HXJVJU"}. Alternatively, an object of class \dQuote{dataverse_dataset} obtained by \code{dataverse_contents()}.} \item{format}{A character string specifying a file format for download. @@ -91,7 +91,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{original}{A logical, defaulting to TRUE. If a ingested (.tab) version is diff --git a/man/get_dataframe.Rd b/man/get_dataframe.Rd index a4a2f90..354c566 100644 --- a/man/get_dataframe.Rd +++ b/man/get_dataframe.Rd @@ -23,7 +23,7 @@ get_dataframe_by_doi(filedoi, .f = NULL, original = FALSE, ...) \code{"roster-bulls-1996.tab"}. Can be a vector for multiple files.} \item{dataset}{A character specifying a persistent identification ID for a dataset, -for example \code{"doi:10.70122/FK2/HXJVJU"}. Alternatively, an object of class +for example \code{"10.70122/FK2/HXJVJU"}. Alternatively, an object of class \dQuote{dataverse_dataset} obtained by \code{dataverse_contents()}.} \item{.f}{The function to used for reading in the raw dataset. The user @@ -62,7 +62,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{\code{return_url}}{Instead of downloading the file, return the URL for download. Defaults to \code{FALSE}.} diff --git a/man/get_dataset.Rd b/man/get_dataset.Rd index 9c574dd..cab1c56 100644 --- a/man/get_dataset.Rd +++ b/man/get_dataset.Rd @@ -33,7 +33,7 @@ dataset_files( } \arguments{ \item{dataset}{A character specifying a persistent identification ID for a dataset, -for example \code{"doi:10.70122/FK2/HXJVJU"}. Alternatively, an object of class +for example \code{"10.70122/FK2/HXJVJU"}. Alternatively, an object of class \dQuote{dataverse_dataset} obtained by \code{dataverse_contents()}.} \item{version}{A character string specifying a version of the dataset. This can be one of \dQuote{:draft} (the current draft), \dQuote{:latest} (the latest draft, if it exists, or the latest published version), \dQuote{:latest-published} (the latest published version, ignoring any draft), or \dQuote{x.y} (where \samp{x} is a major version and \samp{y} is a minor version; the \samp{.y} can be omitted to obtain a major version). In lieu of this, a dataset's version-specific identification number can be used for the \code{dataset} argument.} @@ -48,7 +48,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/get_dataverse.Rd b/man/get_dataverse.Rd index 5328de1..d984700 100644 --- a/man/get_dataverse.Rd +++ b/man/get_dataverse.Rd @@ -33,7 +33,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{check}{A logical indicating whether to check that the value of \code{dataverse} is actually a numeric} diff --git a/man/get_facets.Rd b/man/get_facets.Rd index 0d0777c..54aadcb 100644 --- a/man/get_facets.Rd +++ b/man/get_facets.Rd @@ -24,7 +24,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/get_file_metadata.Rd b/man/get_file_metadata.Rd index 7bd737f..4ec313d 100644 --- a/man/get_file_metadata.Rd +++ b/man/get_file_metadata.Rd @@ -22,7 +22,7 @@ class \dQuote{dataverse_file} as returned by \code{\link{dataset_files}}. Can be a vector for multiple files.} \item{dataset}{A character specifying a persistent identification ID for a dataset, -for example \code{"doi:10.70122/FK2/HXJVJU"}. Alternatively, an object of class +for example \code{"10.70122/FK2/HXJVJU"}. Alternatively, an object of class \dQuote{dataverse_dataset} obtained by \code{dataverse_contents()}.} \item{format}{Defaults to \dQuote{ddi} for metadata files} @@ -37,7 +37,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/get_filesize.Rd b/man/get_filesize.Rd index 0cd370e..17323b0 100644 --- a/man/get_filesize.Rd +++ b/man/get_filesize.Rd @@ -23,7 +23,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} } \value{ diff --git a/man/initiate_sword_dataset.Rd b/man/initiate_sword_dataset.Rd index 0be765d..13893f0 100644 --- a/man/initiate_sword_dataset.Rd +++ b/man/initiate_sword_dataset.Rd @@ -27,7 +27,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/is_ingested.Rd b/man/is_ingested.Rd index dedef22..1198ca6 100644 --- a/man/is_ingested.Rd +++ b/man/is_ingested.Rd @@ -24,7 +24,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Arguments passed on to \code{get_file} (no effect here)} diff --git a/man/list_datasets.Rd b/man/list_datasets.Rd index e077c07..f8f6c08 100644 --- a/man/list_datasets.Rd +++ b/man/list_datasets.Rd @@ -24,7 +24,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/publish_dataset.Rd b/man/publish_dataset.Rd index 0271e99..2b7f27b 100644 --- a/man/publish_dataset.Rd +++ b/man/publish_dataset.Rd @@ -14,7 +14,7 @@ publish_dataset( } \arguments{ \item{dataset}{A character specifying a persistent identification ID for a dataset, -for example \code{"doi:10.70122/FK2/HXJVJU"}. Alternatively, an object of class +for example \code{"10.70122/FK2/HXJVJU"}. Alternatively, an object of class \dQuote{dataverse_dataset} obtained by \code{dataverse_contents()}.} \item{minor}{A logical specifying whether the new release of the dataset is a \dQuote{minor} release (\code{TRUE}, by default), resulting in a minor version increase (e.g., from 1.1 to 1.2). If \code{FALSE}, the dataset is given a \dQuote{major} release (e.g., from 1.1 to 2.0).} @@ -29,7 +29,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/publish_dataverse.Rd b/man/publish_dataverse.Rd index 89e9c4f..fb229ae 100644 --- a/man/publish_dataverse.Rd +++ b/man/publish_dataverse.Rd @@ -24,7 +24,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/publish_sword_dataset.Rd b/man/publish_sword_dataset.Rd index a4227e5..e53e03b 100644 --- a/man/publish_sword_dataset.Rd +++ b/man/publish_sword_dataset.Rd @@ -24,7 +24,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/service_document.Rd b/man/service_document.Rd index 7751d96..3cfac1e 100644 --- a/man/service_document.Rd +++ b/man/service_document.Rd @@ -21,7 +21,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/man/set_dataverse_metadata.Rd b/man/set_dataverse_metadata.Rd index 9876713..6a25f3c 100644 --- a/man/set_dataverse_metadata.Rd +++ b/man/set_dataverse_metadata.Rd @@ -30,7 +30,7 @@ Multiple Dataverse installations exist, with \code{"dataverse.harvard.edu"} bein most major. The server can be defined each time within a function, or it can be set as a default via an environment variable. To set a default, run \code{Sys.setenv("DATAVERSE_SERVER" = "dataverse.harvard.edu")} -or add \verb{DATAVERSE_SERVER = "dataverse.harvard.edu} in one's \code{.Renviron} +or add \code{DATAVERSE_SERVER = "dataverse.harvard.edu"} in one's \code{.Renviron} file (\code{usethis::edit_r_environ()}), with the appropriate domain as its value.} \item{...}{Additional arguments passed to an HTTP request function, such as diff --git a/tests/testthat/tests-dataset_metadata.R b/tests/testthat/tests-dataset_metadata.R index 2fcdfa7..9f722d4 100644 --- a/tests/testthat/tests-dataset_metadata.R +++ b/tests/testthat/tests-dataset_metadata.R @@ -22,6 +22,12 @@ test_that("check versions format", { ds_index <- which(sapply(contents, function(x) x$identifier) == "FK2/HXJVJU") actual <- dataset_versions(contents[[ds_index]]) - expect_length(actual[[1]], 17L) + expected_names <- c( + "citationDate", "createTime", "datasetId", "datasetPersistentId", + "fileAccessRequest", "files", "id", "lastUpdateTime", "latestVersionPublishingState", + "license", "metadataBlocks", "publicationDate", "releaseTime", + "storageIdentifier", "UNF", "versionMinorNumber", "versionNumber", + "versionState") + expect_setequal(names(actual[[1]]), expected_names) expect_s3_class(actual[[2]], "dataverse_dataset_version") }) diff --git a/tests/testthat/tests-dataverse_contents.R b/tests/testthat/tests-dataverse_contents.R index a9664d1..84c01a2 100644 --- a/tests/testthat/tests-dataverse_contents.R +++ b/tests/testthat/tests-dataverse_contents.R @@ -23,6 +23,7 @@ test_that("dataverse for 'dataverse-client-r'", { publisher = "Demo Dataverse", publicationDate = "2020-12-29", storageIdentifier = "file://10.70122/FK2/HXJVJU", + datasetType = "dataset", type = "dataset" ), class = "dataverse_dataset" @@ -31,5 +32,5 @@ test_that("dataverse for 'dataverse-client-r'", { dv <- get_dataverse(dataverse = "dataverse-client-r") actual <- dataverse_contents(dv) ds_index <- which(sapply(actual, function(x) x$identifier) == "FK2/HXJVJU") - expect_equal(actual[[ds_index]], expected) + expect_contains(actual[[ds_index]], expected) # y is a subset of x }) diff --git a/tests/testthat/tests-get_dataframe-dataframe-basketball.R b/tests/testthat/tests-get_dataframe-dataframe-basketball.R index e963b29..d10eece 100644 --- a/tests/testthat/tests-get_dataframe-dataframe-basketball.R +++ b/tests/testthat/tests-get_dataframe-dataframe-basketball.R @@ -10,7 +10,9 @@ test_that("roster-by-name", { actual <- get_dataframe_by_name( filename = expected_ds$roster$label , # A value like "roster-bulls-1996.tab", - dataset = dirname(expected_ds$roster$dataFile$persistentId)#, # A value like "doi:10.70122/FK2/HXJVJU", + dataset = dirname(expected_ds$roster$dataFile$persistentId),#, # A value like "doi:10.70122/FK2/HXJVJU", + # quieten readr::read_tsv during test + .f = function(...) readr::read_tsv(..., show_col_types = FALSE) ) expect_equal(actual, expected_file) @@ -24,7 +26,9 @@ test_that("roster-by-doi", { actual <- get_dataframe_by_doi( - filedoi = expected_ds$roster$dataFile$persistentId # A value like "doi:10.70122/FK2/HXJVJU/SA3Z2V", + filedoi = expected_ds$roster$dataFile$persistentId, # A value like "doi:10.70122/FK2/HXJVJU/SA3Z2V", + # quieten readr::read_tsv during test + .f = function(...) readr::read_tsv(..., show_col_types = FALSE) ) expect_equal(actual, expected_file) @@ -38,7 +42,9 @@ test_that("roster-by-id", { actual <- get_dataframe_by_id( - fileid = expected_ds$roster$dataFile$id # A value like 1734005 + fileid = expected_ds$roster$dataFile$id, # A value like 1734005 + # quieten readr::read_tsv during test + .f = function(...) readr::read_tsv(..., show_col_types = FALSE) ) expect_equal(actual, expected_file) diff --git a/tests/testthat/tests-get_dataset.R b/tests/testthat/tests-get_dataset.R index 212b985..bec0535 100644 --- a/tests/testthat/tests-get_dataset.R +++ b/tests/testthat/tests-get_dataset.R @@ -10,8 +10,15 @@ test_that("download tab from DOI and filename", { actual <- get_dataset(contents[[ds_index]]) files <- actual$files expected_dv <- retrieve_info_dataverse("expected-dataverse.yml") + expected_names <- c( + "citationDate", "createTime", "datasetId", + "datasetPersistentId", "fileAccessRequest", "files", "id", + "lastUpdateTime", "latestVersionPublishingState", "license", + "metadataBlocks", "publicationDate", "releaseTime", + "storageIdentifier", "UNF", "versionMinorNumber", + "versionNumber", "versionState") - expect_length(actual , 17L) + expect_setequal(names(actual) , expected_names) expect_equal(actual$id , 182158L) expect_equal(actual$datasetId , 1734004L) expect_equal(actual$datasetPersistentId , "doi:10.70122/FK2/HXJVJU") diff --git a/tests/testthat/tests-search.R b/tests/testthat/tests-search.R index 11dfccd..1f00236 100644 --- a/tests/testthat/tests-search.R +++ b/tests/testthat/tests-search.R @@ -1,34 +1,34 @@ test_that("simple search query", { testthat::skip_on_cran() - expect_true(is.data.frame(dataverse_search("Gary King", key = "", server = "dataverse.harvard.edu"))) + expect_true(is.data.frame(dataverse_search("Gary King", key = "", server = "dataverse.harvard.edu", verbose = FALSE))) }) test_that("named argument search", { testthat::skip_on_cran() - expect_true(is.data.frame(dataverse_search(author = "Gary King", title = "Ecological Inference", key = "", server = "dataverse.harvard.edu"))) + expect_true(is.data.frame(dataverse_search(author = "Gary King", title = "Ecological Inference", key = "", server = "dataverse.harvard.edu", verbose = FALSE))) }) test_that("simple search w/type argument", { testthat::skip_on_cran() - expect_true(is.data.frame(dataverse_search(author = "Gary King", type = "dataset", key = "", server = "dataverse.harvard.edu"))) + expect_true(is.data.frame(dataverse_search(author = "Gary King", type = "dataset", key = "", server = "dataverse.harvard.edu", verbose = FALSE))) }) test_that("date range search using fq", { testthat::skip_on_cran() - expect_true(is.data.frame(dataverse_search("*", fq = "dateSort:[2018-01-01T00:00:00Z+TO+2019-01-01T00:00:00Z]", type = "dataset", key = "", server = "dataverse.harvard.edu"))) + expect_true(is.data.frame(dataverse_search("*", fq = "dateSort:[2018-01-01T00:00:00Z+TO+2019-01-01T00:00:00Z]", type = "dataset", key = "", server = "dataverse.harvard.edu", verbose = FALSE))) }) test_that("publication year using fq", { testthat::skip_on_cran() - expect_true(is.data.frame(dataverse_search("*", fq = "publicationDate:2018", type = "dataset", key = "", server = "dataverse.harvard.edu"))) + expect_true(is.data.frame(dataverse_search("*", fq = "publicationDate:2018", type = "dataset", key = "", server = "dataverse.harvard.edu", verbose = FALSE))) }) test_that("filter dataverses by subject using fq", { testthat::skip_on_cran() - expect_true(is.data.frame(dataverse_search("*", fq = "subject_ss:Social+Sciences", type = "dataverse", key = "", server = "dataverse.harvard.edu"))) + expect_true(is.data.frame(dataverse_search("*", fq = "subject_ss:Social+Sciences", type = "dataverse", key = "", server = "dataverse.harvard.edu", verbose = FALSE))) }) test_that("empty fq search", { testthat::skip_on_cran() - expect_length(dataverse_search("*", fq = "dateSort:[2019-02-01T00:00:00Z+TO+2019-01-01T00:00:00Z]", type = "dataset", key = "", server = "dataverse.harvard.edu"), 0) + expect_length(dataverse_search("*", fq = "dateSort:[2019-02-01T00:00:00Z+TO+2019-01-01T00:00:00Z]", type = "dataset", key = "", server = "dataverse.harvard.edu", verbose = FALSE), 0) })