Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pull dev updates to #42 #48

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
# Generated by roxygen2: do not edit by hand

S3method(set_metadata_ref,data_metadata)
S3method(set_metadata_ref,datasetjson)
S3method(set_metadata_ref,default)
S3method(set_metadata_version,data_metadata)
S3method(set_metadata_version,datasetjson)
S3method(set_metadata_version,default)
S3method(set_study_oid,data_metadata)
S3method(set_study_oid,datasetjson)
S3method(set_study_oid,default)
export(data_metadata)
export(dataset_json)
export(dataset_metadata)
export(file_metadata)
export(read_dataset_json)
export(set_data_type)
export(set_dataset_label)
export(set_dataset_name)
export(set_file_oid)
export(set_item_oid)
export(set_last_modified)
export(set_metadata_ref)
export(set_metadata_version)
export(set_originator)
export(set_reference_data)
export(set_source_system)
export(set_study_oid)
export(validate_dataset_json)
Expand Down
56 changes: 56 additions & 0 deletions R/archive/data_metadata.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#' Create the data metadata container for a Dataset JSON object
#'
#' @param study Study OID value
#' @param metadata_version Metadata version OID value
#' @param metadata_ref Metadata reference (i.e. path to Define.xml)
#'
#' @return data_metadata object
#' @export
#'
#' @examples
#' # Create object directly
#' data_meta <- data_metadata(
#' study = "SOMESTUDY",
#' metadata_version = "MDV.MSGv2.0.SDTMIG.3.3.SDTM.1.7",
#' metadata_ref = "some/define.xml"
#' )
#'
#' # Use setter functions
#' data_meta <- data_metadata()
#' data_meta_updated <- set_metadata_ref(data_meta, "some/define.xml")
#' data_meta_updated <- set_metadata_version(data_meta_updated, "MDV.MSGv2.0.SDTMIG.3.3.SDTM.1.7")
#' data_meta_updated <- set_study_oid(data_meta_updated, "SOMESTUDY")
#'
data_metadata <- function(study = NULL, metadata_version = NULL, metadata_ref = NULL) {

x <- list(
studyOID = study,
metaDataVersionOID = metadata_version,
metaDataRef = metadata_ref,
itemGroupData = NULL
)

structure(
x,
class = c("data_metadata", "list")
)
}

#' Set data metadata parameters
#'
#' This set of functions
#' @param x data metadata or datasetjson object
#' @param study Study OID value
#' @param ... Additional parameters
#'
#' @return A datasetjson or data_metadata object
#' @export
#'
#' @family Data metadata setters
#' @rdname data_metadata_setters
#'
#' @examples
#' data_meta <- data_metadata()
#' data_meta_updated <- set_metadata_ref(data_meta, "some/define.xml")
#' data_meta_updated <- set_metadata_version(data_meta_updated, "MDV.MSGv2.0.SDTMIG.3.3.SDTM.1.7")
#' data_meta_updated <- set_study_oid(data_meta_updated, "SOMESTUDY")
File renamed without changes.
32 changes: 32 additions & 0 deletions R/column_classes.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file contains several helpers for reading and writing date / datetime
# columns from a Dataset JSON file

#' Get the column classes off a data frame
#'
#' @param x A data.frame
#'
#' @return Named character vector of columns and types
#' @noRd
get_column_classes <- function(x) {
vapply(x, function(X) class(X)[1], FUN.VALUE=character(1))
}

#' Get the columns with a class of Date from a data.frame
#'
#' @param x A data.frame
#'
#' @return A data.frame
#' @noRd
get_date_cols <- function(x) {
x[get_column_classes(x) == "Date"]
}

#' Get the columns with a class of POSIXct from a data.frame
#'
#' @param x A data.frame
#'
#' @return A data.frame
#' @noRd
get_datetime_cols <- function(x) {
x[get_column_classes(x) == "POSIXct"]
}
41 changes: 4 additions & 37 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,12 @@
#' }
"iris_items"

#' A List of valid SAS(c) date formats
#' Dataset JSON Schema Version 1.1.0
#'
#' Valid SAS(c) date formats pulled from
#' https://documentation.sas.com/doc/en/vdmmlcdc/8.1/ds2pg/p0bz5detpfj01qn1kz2in7xymkdl.htm
#' This object is a character vector holding the schema for Dataset JSON Version 1.1.0
#'
#' @format ## `sas_date_formats`
#' \describe{
#' A character vector with 45 elements
#' }
"sas_date_formats"

#' A List of valid SAS(c) datetime formats
#'
#' Valid SAS(c) datetime formats pulled from
#' https://documentation.sas.com/doc/en/vdmmlcdc/8.1/ds2pg/p0bz5detpfj01qn1kz2in7xymkdl.htm
#'
#' @format ## `sas_datetime_formats`
#' \describe{
#' A character vector with 7 elements
#' }
"sas_datetime_formats"

#' A List of valid SAS(c) time formats
#'
#' Valid SAS(c) time formats pulled from
#' https://documentation.sas.com/doc/en/vdmmlcdc/8.1/ds2pg/p0bz5detpfj01qn1kz2in7xymkdl.htm
#'
#' @format ## `sas_time_formats`
#' \describe{
#' A character vector with 4 elements
#' }
"sas_time_formats"

#' Dataset JSON Schema Version 1.0.0
#'
#' This object is a character vector holding the schema for Dataset JSON Version 1.0.0
#'
#' @format ## `schema_1_0_0`
#' @format ## `schema_1_1_0`
#' \describe{
#' A character vector with 1 element
#' }
"schema_1_0_0"
"schema_1_1_0"
138 changes: 0 additions & 138 deletions R/data_metadata.R

This file was deleted.

Loading
Loading