Skip to content

Commit

Permalink
Recording source
Browse files Browse the repository at this point in the history
  • Loading branch information
antaldaniel committed Nov 23, 2023
1 parent 90880b3 commit d6d99d6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 11 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: dataset
Title: Create Data Frames that are Easier to Exchange and Reuse
Date: 2023-03-18
Version: 0.2.1
Date: 2023-11-23
Version: 0.2.2
Authors@R:
c(person(given = "Daniel", family = "Antal",
email = "daniel.antal@dataobservatory.eu",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# New devel branch

The devel branch contains new code that is not is validated, but as a whole the package is not working consistently.

0.2.2: New s3 classes for DataCite and Dublin Core bibliographic entries.


# dataset 0.2.1

Expand Down
4 changes: 3 additions & 1 deletion R/as_bibentry.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ as_bibentry <- function(bibtype="Misc",

tmp$author <- c(tmp$author, arguments$contributor)
}

if (!is.null(arguments$date)) tmp$date <- arguments$date
if (!is.null(arguments$type)) tmp$type <- arguments$type
if (!is.null(arguments$coverage)) tmp$coverage <- arguments$coverage
if (!is.null(arguments$source)) tmp$source <- arguments$source
if (!is.null(arguments$datasource)) tmp$source <- arguments$datasource
if (!is.null(arguments$geolocation)) tmp$geolocation <- arguments$geolocation
if (!is.null(arguments$fundingreference)) tmp$fundingreference <- arguments$fundingreference

tmp
}

10 changes: 6 additions & 4 deletions R/as_dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ as_dataset <- function(x,
description = NULL,
version = NULL,
subject = NULL,
language = NULL) {
language = NULL,
datasource = NULL) {
UseMethod("as_dataset", x)
}

Expand All @@ -26,7 +27,8 @@ as_dataset.data.frame <- function(x,
description = NULL,
version = NULL,
subject = NULL,
language = NULL) {
language = NULL,
datasource = NULL) {

DataBibentry <- utils::bibentry(bibtype="Misc",
title = title,
Expand All @@ -37,8 +39,8 @@ as_dataset.data.frame <- function(x,
identifier = identifier,
version = version,
description = description,
language = language
)
language = language,
source = datasource )

if (is.null(subject)) subject <- new_Subject("")

Expand Down
7 changes: 6 additions & 1 deletion R/dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#' an R object.
#' @param language The primary language of the dataset, for example \code{'eng'}.
#' Defaults to \code{NULL} that sets it to the unassigned value \code{':unas'}.
#' @param datasource The source of the dataset,
#' \href{https://www.dublincore.org/specifications/dublin-core/dcmi-terms/elements11/source/}{DCMI: Source},
#' which corresponds to a \code{relatedItem} in the DataCite vocabulary.
#' @return A dataset object, which is a data.frame or inherited object with rich
#' metadata.
#' @examples
Expand Down Expand Up @@ -49,6 +52,7 @@ dataset <- function(x,
subject = NULL,
description = NULL,
language = NULL,
datasource = NULL
... ) {

arguments <- list(...)
Expand All @@ -61,7 +65,8 @@ dataset <- function(x,
year=year,
version=version,
subject=subject,
language=language)
language=language,
datasource=datasource)
}

#' @keywords internal
Expand Down
4 changes: 3 additions & 1 deletion tests/testthat/test-as_bibentry.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
myBibentry <- as_bibentry(author = c(person(family ="Anderson", given ="Edgar",
role = "aut")),
title = "The iris Dataset")
title = "The iris Dataset",
datasource = "https://zenodo.org/record/7421899/files/iris.csv?download=1")


test_that("as_bibentry() internal function works", {
Expand All @@ -9,6 +10,7 @@ test_that("as_bibentry() internal function works", {
expect_equal(myBibentry$publisher, ":tba")
expect_equal(myBibentry$identifier, ":tba")
expect_equal(myBibentry$version, "0.1.0")
expect_equal(myBibentry$source, "https://zenodo.org/record/7421899/files/iris.csv?download=1")
expect_equal(myBibentry$description, ":unas")
expect_equal(myBibentry$year, substr(as.character(Sys.Date()),1,4))
})
7 changes: 5 additions & 2 deletions tests/testthat/test-as_dataset.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
myiris <- iris
converted <- as_dataset(iris,
converted <- as_dataset(x=iris,
author = c(person(family ="Anderson", given ="Edgar",
role = "aut")),
title = "The iris Dataset")
title = "The iris Dataset",
datasource = "https://zenodo.org/record/7421899/files/iris.csv?download=1")

test_that("as_dataset method works", {
expect_true(is.dataset(converted))
Expand All @@ -16,4 +17,6 @@ test_that("as_dataset method works", {
"The iris Dataset")
expect_equal(attr(converted, "DataBibentry")$resourcetype,
"Dataset")
expect_equal(attr(converted, "DataBibentry")$source,
source = "https://zenodo.org/record/7421899/files/iris.csv?download=1")
})

0 comments on commit d6d99d6

Please sign in to comment.