Skip to content

Commit

Permalink
New devel-branch with from the sandbox repo dsdev
Browse files Browse the repository at this point in the history
  • Loading branch information
antaldaniel committed Nov 17, 2023
1 parent 9305b34 commit c8bf715
Show file tree
Hide file tree
Showing 18 changed files with 328 additions and 895 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ inst/doc
not_included/
/doc/
/Meta/

old-functions/
20 changes: 3 additions & 17 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
# Generated by roxygen2: do not edit by hand

S3method("[",dataset)
S3method(as.data.frame,dataset)
S3method(as_dataset,data.frame)
S3method(describe,dataset)
S3method(print,dataset)
S3method(subset,dataset)
S3method(summary,dataset)
export("attributes_measures<-")
export("creator<-")
export("dataset_source<-")
export("dataset_title<-")
export("description<-")
export("dimensions<-")
export("geolocation<-")
export("identifier<-")
export("language<-")
export("measures<-")
export("publication_year<-")
export("publisher<-")
export("resource_type<-")
export("resource_type_general<-")
export("rights<-")
export("subject<-")
export("version<-")
export(as.data.frame)
export(attributes_measures)
export(as_dataset)
export(bibentry_dataset)
export(creator)
export(datacite)
Expand All @@ -38,21 +31,15 @@ export(dataset_title)
export(dataset_title_create)
export(dataset_uri)
export(description)
export(dimensions)
export(dublincore)
export(dublincore_add)
export(geolocation)
export(identifier)
export(is.dataset)
export(language)
export(measures)
export(publication_year)
export(publisher)
export(related_item)
export(resource_type)
export(resource_type_general)
export(resource_type_general_allowed)
export(resource_type_general_verify)
export(rights)
export(size)
export(subject)
Expand All @@ -66,6 +53,5 @@ importFrom(utils,download.file)
importFrom(utils,object.size)
importFrom(utils,person)
importFrom(utils,read.csv)
importFrom(utils,toBibtex)
importFrom(utils,write.csv)
importFrom(utils,write.table)
58 changes: 58 additions & 0 deletions R/as_dataset.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

#' @rdname dataset
#' @export
as_dataset <- function(x,
author,
title,
publisher = NULL,
year = NULL,
identifier = NULL,
description = NULL,
version = NULL,
subject = NULL,
language = NULL) {
UseMethod("as_dataset", x)
}

#' @rdname dataset
#' @importFrom utils bibentry
#' @export
as_dataset.data.frame <- function(x,
author,
title,
publisher = NULL,
year = NULL,
identifier = NULL,
description = NULL,
version = NULL,
subject = NULL,
language = NULL) {

assertthat::assert_that(inherits(author, "person"),
msg="The person person must be created with utils::person().")

if (is.null(year)) year <- substr(as.character(Sys.Date()), 1,4)
if (is.null(version)) version <- "0.1.0" else version <- as.character(version)
if (is.null(publisher)) publisher <- ":tba"
if (is.null(identifier)) identifier <- ":tba"
if (is.null(description)) description <- ":unas"
if (is.null(language)) language <- ":unas"
if (is.null(subject)) subject <- new_Subject(NULL)

DataBibentry <- utils::bibentry(bibtype="Misc",
title = title,
author = author,
publisher = publisher,
year = year,
resourceType = "Dataset",
identifier = identifier,
version = version,
description = description,
language = language
)

new_dataset(x,
DataBibentry = DataBibentry,
subject = subject)

}
Loading

0 comments on commit c8bf715

Please sign in to comment.