From 7782175b85eca6da5a57efa861e44a36bea91a0e Mon Sep 17 00:00:00 2001 From: Mahmoud Hallal Date: Fri, 24 Feb 2023 17:35:43 +0100 Subject: [PATCH 1/7] new tdata --- R/tdata.R | 183 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 R/tdata.R diff --git a/R/tdata.R b/R/tdata.R new file mode 100644 index 000000000..c2ba95567 --- /dev/null +++ b/R/tdata.R @@ -0,0 +1,183 @@ +#' Create a `tdata` Object +#' +#' Create a new object called `tdata` which contains `data`, a `reactive` list of data.frames +#' (or `MultiAssayExperiment`), with attributes: +#' \itemize{ +#' \item{`code` (`reactive`) containing code used to generate the data} +#' \item{join_keys (`JoinKeys`) containing the relationships between the data} +#' \item{metadata (`named list`) containing any metadata associated with the data frames} +#' } +#' @name tdata +#' @param data A `named list` of `data.frames` (or `MultiAssayExperiment`) +#' which optionally can be `reactive`. +#' Inside this object all of these items will be made `reactive`. +#' @param code A `character` (or `reactive` which evaluates to a `character`) containing +#' the code used to generate the data. This should be `reactive` if the code is changing +#' during a reactive context (e.g. if filtering changes the code). Inside this +#' object `code` will be made reactive +#' @param join_keys A `teal.data::JoinKeys` object containing relationships between the +#' datasets. +#' @param metadata A `named list` each element contains a list of metadata about the named data.frame +#' Each element of these list should be atomic and length one. +#' @return A `tdata` object +#' @examples +#' +#' data <- new_tdata( +#' data = list(iris = iris, mtcars = reactive(mtcars), dd = data.frame(x = 1:10)), +#' code = "iris <- iris +#' mtcars <- mtcars +#' dd <- data.frame(x = 1:10)", +#' metadata = list(dd = list(author = "NEST"), iris = list(version = 1)) +#' ) +#' +#' # Extract a data.frame +#' isolate(data[["iris"]]()) +#' +#' # Get code +#' isolate(get_code(data)) +#' +#' # Get metadata +#' get_metadata(data, "iris") +#' +#' @export +new_tdata <- function(data, code = "", join_keys = NULL, metadata = NULL, check = FALSE, label) { + checkmate::assert_list( + data, + any.missing = FALSE, names = "unique", + types = c("data.frame", "reactive", "MultiAssayExperiment") + ) + checkmate::assert_class(join_keys, "JoinKeys", null.ok = TRUE) + checkmate::assert_multi_class(code, c("character", "reactive", "CodeClass")) + + checkmate::assert_list(metadata, names = "unique", null.ok = TRUE) + checkmate::assert_subset(names(metadata), names(data)) + for (m in metadata) teal.data::validate_metadata(m) + + if (is.reactive(code)) { + isolate(checkmate::assert_multi_class(code(), c("character", "CodeClass"), .var.name = "code")) + } + + # create reactive data.frames + for (x in names(data)) { + if (!is.reactive(data[[x]])) { + data[[x]] <- do.call(reactive, list(as.name(x)), envir = list2env(data[x])) + } else { + isolate( + checkmate::assert_multi_class( + data[[x]](), c("data.frame", "MultiAssayExperiment"), + .var.name = "data" + ) + ) + } + } + + # code + # code <- if (is.reactive(code) && is.character(code())) { + # CodeClass$new(code()) + # } else if (is.character(code)) { + # CodeClass$new(code) + # } + + # set attributes + attr(data, "code") <- code + attr(data, "join_keys") <- join_keys + attr(data, "metadata") <- metadata + attr(data, "check") <- check + attr(data, "label") <- label + + # set class + class(data) <- c("tdata", class(data)) + data +} + +#' Function to convert a `tdata` object to an `environment` +#' Any `reactives` inside `tdata` are first evaluated +#' @param data a `tdata` object +#' @return an `environment` +#' @examples +#' +#' data <- new_tdata( +#' data = list(iris = iris, mtcars = reactive(mtcars)), +#' code = "iris <- iris +#' mtcars = mtcars", +#' label = list(iris = "iris", mtcars = "mtcars") +#' ) +#' +#' my_env <- isolate(tdata2env(data)) +#' +#' @export +tdata2env <- function(data) { # nolint + checkmate::assert_class(data, "tdata") + list2env(lapply(data, function(x) if (is.reactive(x)) x() else x)) +} + +#' @rdname tdata +#' @param x a `tdata` object +#' @param ... additional arguments for the generic +#' @export +get_code.tdata <- function(x, ...) { # nolint + # note teal.data which teal depends on defines the get_code method + attr(x, "code")()#$get_code() +} + + +#' Wrapper for `get_code.tdata` +#' This wrapper is to be used by downstream packages to extract the code of a `tdata` object +#' +#' @param data (`tdata`) object +#' +#' @return (`character`) code used in the `tdata` object. +#' @export +get_code_tdata <- function(data) { + checkmate::assert_class(data, "tdata") + get_code(data) +} + + +#' Function to get join keys from a `tdata` object +#' @param data `tdata` - object to extract the join keys +#' @return Either `JoinKeys` object or `NULL` if no join keys +#' @export +get_join_keys <- function(data) { + UseMethod("get_join_keys", data) +} + + +#' @rdname get_join_keys +#' @export +get_join_keys.tdata <- function(data) { + attr(data, "join_keys") +} + + +#' @rdname get_join_keys +#' @export +get_join_keys.default <- function(data) { + stop("get_join_keys function not implemented for this object") +} + +#' Function to get metadata from a `tdata` object +#' @param data `tdata` - object to extract the data from +#' @param dataname `character(1)` the dataset name whose metadata is requested +#' @return Either list of metadata or NULL if no metadata +#' @export +get_metadata <- function(data, dataname) { + checkmate::assert_string(dataname) + UseMethod("get_metadata", data) +} + +#' @rdname get_metadata +#' @export +get_metadata.tdata <- function(data, dataname) { + metadata <- attr(data, "metadata") + if (is.null(metadata)) { + return(NULL) + } + metadata[[dataname]] +} + +#' @rdname get_metadata +#' @export +get_metadata.default <- function(data, dataname) { + stop("get_metadata function not implemented for this object") +} From 39a58ada5259e473e0a2d2f58de02128351f4b0a Mon Sep 17 00:00:00 2001 From: Mahmoud Hallal Date: Fri, 24 Feb 2023 17:35:56 +0100 Subject: [PATCH 2/7] get_tdata --- R/TealData.R | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/R/TealData.R b/R/TealData.R index eede288e3..502f5684a 100644 --- a/R/TealData.R +++ b/R/TealData.R @@ -193,6 +193,28 @@ TealData <- R6::R6Class( # nolint private$join_keys$get_parents() }, + #' @description + #' returns the tdata object. + #' + #' @return (`tdata`) object of the datasets. + get_tdata = function() { + datanames <- self$get_datanames() + df_list <- lapply(datanames, function(x) self$get_dataset(x)$get_raw_data()) + names(df_list) <- datanames + md_list <- lapply(datanames, function(x) self$get_dataset(x)$get_metadata()) + names(md_list) <- datanames + labels_list <- lapply(datanames, function(x) self$get_dataset(x)$get_dataset_label()) + names(md_list) <- datanames + + teal.data::new_tdata( + data = df_list, + join_keys = self$get_join_keys(), + code = self$get_code_class(), + metadata = md_list, + check = self$get_check(), + label = labels_list + ) + }, # ___ shiny ==== #' @description From 3b373d1595c62c58fff54bbb564ffdb4e6fe6d24 Mon Sep 17 00:00:00 2001 From: Mahmoud Hallal Date: Fri, 24 Feb 2023 17:36:06 +0100 Subject: [PATCH 3/7] docs --- NAMESPACE | 10 ++++++ man/TealData.Rd | 14 +++++++++ man/get_code_tdata.Rd | 19 ++++++++++++ man/get_join_keys.Rd | 23 ++++++++++++++ man/get_metadata.Rd | 25 +++++++++++++++ man/tdata.Rd | 71 +++++++++++++++++++++++++++++++++++++++++++ man/tdata2env.Rd | 31 +++++++++++++++++++ 7 files changed, 193 insertions(+) create mode 100644 man/get_code_tdata.Rd create mode 100644 man/get_join_keys.Rd create mode 100644 man/get_metadata.Rd create mode 100644 man/tdata.Rd create mode 100644 man/tdata2env.Rd diff --git a/NAMESPACE b/NAMESPACE index 122ea7119..f97715c88 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,6 +9,7 @@ S3method(get_code,TealDataAbstract) S3method(get_code,TealDataset) S3method(get_code,TealDatasetConnector) S3method(get_code,default) +S3method(get_code,tdata) S3method(get_dataname,TealDataAbstract) S3method(get_dataname,TealDataset) S3method(get_dataname,TealDatasetConnector) @@ -20,11 +21,15 @@ S3method(get_dataset_label,TealDatasetConnector) S3method(get_datasets,TealDataAbstract) S3method(get_datasets,TealDataset) S3method(get_datasets,TealDatasetConnector) +S3method(get_join_keys,default) +S3method(get_join_keys,tdata) S3method(get_key_duplicates,TealDataset) S3method(get_key_duplicates,data.frame) S3method(get_keys,TealDataAbstract) S3method(get_keys,TealDataset) S3method(get_keys,TealDatasetConnector) +S3method(get_metadata,default) +S3method(get_metadata,tdata) S3method(get_raw_data,TealDataAbstract) S3method(get_raw_data,TealDataset) S3method(get_raw_data,TealDatasetConnector) @@ -81,13 +86,16 @@ export(fun_dataset_connector) export(get_attrs) export(get_cdisc_keys) export(get_code) +export(get_code_tdata) export(get_dataname) export(get_dataset) export(get_dataset_label) export(get_datasets) +export(get_join_keys) export(get_key_duplicates) export(get_keys) export(get_labels) +export(get_metadata) export(get_raw_data) export(is_pulled) export(join_key) @@ -98,6 +106,7 @@ export(mae_dataset) export(mutate_data) export(mutate_dataset) export(mutate_join_keys) +export(new_tdata) export(python_cdisc_dataset_connector) export(python_code) export(python_dataset_connector) @@ -111,6 +120,7 @@ export(script_cdisc_dataset_connector) export(script_dataset_connector) export(set_args) export(set_keys) +export(tdata2env) export(teal_data) export(teal_data_file) export(to_relational_data) diff --git a/man/TealData.Rd b/man/TealData.Rd index 9801797f6..e91407dcf 100644 --- a/man/TealData.Rd +++ b/man/TealData.Rd @@ -63,6 +63,7 @@ get_raw_data(tc) \item \href{#method-TealData-get_items}{\code{TealData$get_items()}} \item \href{#method-TealData-get_join_keys}{\code{TealData$get_join_keys()}} \item \href{#method-TealData-get_parents}{\code{TealData$get_parents()}} +\item \href{#method-TealData-get_tdata}{\code{TealData$get_tdata()}} \item \href{#method-TealData-get_ui}{\code{TealData$get_ui()}} \item \href{#method-TealData-get_server}{\code{TealData$get_server()}} \item \href{#method-TealData-launch}{\code{TealData$launch()}} @@ -232,6 +233,19 @@ named (\code{list}) of the parents of all datasets. } } \if{html}{\out{
}} +\if{html}{\out{}} +\if{latex}{\out{\hypertarget{method-TealData-get_tdata}{}}} +\subsection{Method \code{get_tdata()}}{ +returns the tdata object. +\subsection{Usage}{ +\if{html}{\out{
}}\preformatted{TealData$get_tdata()}\if{html}{\out{
}} +} + +\subsection{Returns}{ +(\code{tdata}) object of the datasets. +} +} +\if{html}{\out{
}} \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-TealData-get_ui}{}}} \subsection{Method \code{get_ui()}}{ diff --git a/man/get_code_tdata.Rd b/man/get_code_tdata.Rd new file mode 100644 index 000000000..c220f2995 --- /dev/null +++ b/man/get_code_tdata.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tdata.R +\name{get_code_tdata} +\alias{get_code_tdata} +\title{Wrapper for \code{get_code.tdata} +This wrapper is to be used by downstream packages to extract the code of a \code{tdata} object} +\usage{ +get_code_tdata(data) +} +\arguments{ +\item{data}{(\code{tdata}) object} +} +\value{ +(\code{character}) code used in the \code{tdata} object. +} +\description{ +Wrapper for \code{get_code.tdata} +This wrapper is to be used by downstream packages to extract the code of a \code{tdata} object +} diff --git a/man/get_join_keys.Rd b/man/get_join_keys.Rd new file mode 100644 index 000000000..d69ef17f9 --- /dev/null +++ b/man/get_join_keys.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tdata.R +\name{get_join_keys} +\alias{get_join_keys} +\alias{get_join_keys.tdata} +\alias{get_join_keys.default} +\title{Function to get join keys from a \code{tdata} object} +\usage{ +get_join_keys(data) + +\method{get_join_keys}{tdata}(data) + +\method{get_join_keys}{default}(data) +} +\arguments{ +\item{data}{\code{tdata} - object to extract the join keys} +} +\value{ +Either \code{JoinKeys} object or \code{NULL} if no join keys +} +\description{ +Function to get join keys from a \code{tdata} object +} diff --git a/man/get_metadata.Rd b/man/get_metadata.Rd new file mode 100644 index 000000000..31bf8dc0a --- /dev/null +++ b/man/get_metadata.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tdata.R +\name{get_metadata} +\alias{get_metadata} +\alias{get_metadata.tdata} +\alias{get_metadata.default} +\title{Function to get metadata from a \code{tdata} object} +\usage{ +get_metadata(data, dataname) + +\method{get_metadata}{tdata}(data, dataname) + +\method{get_metadata}{default}(data, dataname) +} +\arguments{ +\item{data}{\code{tdata} - object to extract the data from} + +\item{dataname}{\code{character(1)} the dataset name whose metadata is requested} +} +\value{ +Either list of metadata or NULL if no metadata +} +\description{ +Function to get metadata from a \code{tdata} object +} diff --git a/man/tdata.Rd b/man/tdata.Rd new file mode 100644 index 000000000..786c3accb --- /dev/null +++ b/man/tdata.Rd @@ -0,0 +1,71 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tdata.R +\name{tdata} +\alias{tdata} +\alias{new_tdata} +\alias{get_code.tdata} +\title{Create a \code{tdata} Object} +\usage{ +new_tdata( + data, + code = "", + join_keys = NULL, + metadata = NULL, + check = FALSE, + label +) + +\method{get_code}{tdata}(x, ...) +} +\arguments{ +\item{data}{A \verb{named list} of \code{data.frames} (or \code{MultiAssayExperiment}) +which optionally can be \code{reactive}. +Inside this object all of these items will be made \code{reactive}.} + +\item{code}{A \code{character} (or \code{reactive} which evaluates to a \code{character}) containing +the code used to generate the data. This should be \code{reactive} if the code is changing +during a reactive context (e.g. if filtering changes the code). Inside this +object \code{code} will be made reactive} + +\item{join_keys}{A \code{teal.data::JoinKeys} object containing relationships between the +datasets.} + +\item{metadata}{A \verb{named list} each element contains a list of metadata about the named data.frame +Each element of these list should be atomic and length one.} + +\item{x}{a \code{tdata} object} + +\item{...}{additional arguments for the generic} +} +\value{ +A \code{tdata} object +} +\description{ +Create a new object called \code{tdata} which contains \code{data}, a \code{reactive} list of data.frames +(or \code{MultiAssayExperiment}), with attributes: +\itemize{ +\item{\code{code} (\code{reactive}) containing code used to generate the data} +\item{join_keys (\code{JoinKeys}) containing the relationships between the data} +\item{metadata (\verb{named list}) containing any metadata associated with the data frames} +} +} +\examples{ + +data <- new_tdata( + data = list(iris = iris, mtcars = reactive(mtcars), dd = data.frame(x = 1:10)), + code = "iris <- iris + mtcars <- mtcars + dd <- data.frame(x = 1:10)", + metadata = list(dd = list(author = "NEST"), iris = list(version = 1)) +) + +# Extract a data.frame +isolate(data[["iris"]]()) + +# Get code +isolate(get_code(data)) + +# Get metadata +get_metadata(data, "iris") + +} diff --git a/man/tdata2env.Rd b/man/tdata2env.Rd new file mode 100644 index 000000000..c7e267048 --- /dev/null +++ b/man/tdata2env.Rd @@ -0,0 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tdata.R +\name{tdata2env} +\alias{tdata2env} +\title{Function to convert a \code{tdata} object to an \code{environment} +Any \code{reactives} inside \code{tdata} are first evaluated} +\usage{ +tdata2env(data) +} +\arguments{ +\item{data}{a \code{tdata} object} +} +\value{ +an \code{environment} +} +\description{ +Function to convert a \code{tdata} object to an \code{environment} +Any \code{reactives} inside \code{tdata} are first evaluated +} +\examples{ + +data <- new_tdata( + data = list(iris = iris, mtcars = reactive(mtcars)), + code = "iris <- iris + mtcars = mtcars", + label = list(iris = "iris", mtcars = "mtcars") +) + +my_env <- isolate(tdata2env(data)) + +} From 711457c2e671fb972cb09e1c708870241026f950 Mon Sep 17 00:00:00 2001 From: Mahmoud Hallal Date: Fri, 24 Feb 2023 17:36:10 +0100 Subject: [PATCH 4/7] tests --- tests/testthat/test-utils.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index e3a315dc9..628e39789 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -16,7 +16,7 @@ test_that("get_key_duplicates_util function", { expect_error(get_key_duplicates_util(df, keys = c("a", "test"))) # single duplicated value - expect_true(dplyr::all_equal( + expect_true(all.equal( data.frame(a = factor("b", levels = c("a", "b", "c")), b = 3, rows = "3,4", n = 2L), get_key_duplicates_util(df, keys) )) @@ -28,7 +28,7 @@ test_that("get_key_duplicates_util function", { stringsAsFactors = TRUE ) keys <- c("a") - expect_true(dplyr::all_equal( + expect_true(all.equal( data.frame(a = factor(c("a", "b"), levels = c("a", "b", "c")), rows = c("1,2", "3,4"), n = c(2L, 2L)), get_key_duplicates_util(df, keys) )) @@ -40,7 +40,7 @@ test_that("get_key_duplicates_util function", { ) keys <- c("a", "b") - expect_true(dplyr::all_equal( + expect_true(all.equal( data.frame(a = factor(x = NULL, levels = c("a", "b", "c")), b = double(0), rows = character(0), n = integer(0)), get_key_duplicates_util(df, keys) )) From c83263b8dbc7dc1cb9c2599a30db175450f0885a Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 24 Feb 2023 17:08:59 +0000 Subject: [PATCH 5/7] [skip actions] Restyle files --- R/tdata.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/tdata.R b/R/tdata.R index c2ba95567..be2904bf7 100644 --- a/R/tdata.R +++ b/R/tdata.R @@ -117,7 +117,7 @@ tdata2env <- function(data) { # nolint #' @export get_code.tdata <- function(x, ...) { # nolint # note teal.data which teal depends on defines the get_code method - attr(x, "code")()#$get_code() + attr(x, "code")() # $get_code() } From 1978ffaff0b443f813dac14511cf52a0e83bffc8 Mon Sep 17 00:00:00 2001 From: Mahmoud Hallal Date: Mon, 27 Feb 2023 09:25:56 +0100 Subject: [PATCH 6/7] empty --- R/tdata.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/tdata.R b/R/tdata.R index c2ba95567..2b3fa0413 100644 --- a/R/tdata.R +++ b/R/tdata.R @@ -71,6 +71,7 @@ new_tdata <- function(data, code = "", join_keys = NULL, metadata = NULL, check } } + # code # code <- if (is.reactive(code) && is.character(code())) { # CodeClass$new(code()) From f7798a59eaf1c8735171eec95d17ca8d604fbd5f Mon Sep 17 00:00:00 2001 From: Mahmoud Hallal Date: Mon, 27 Feb 2023 10:56:39 +0100 Subject: [PATCH 7/7] fixes --- R/TealData.R | 2 +- R/tdata.R | 30 +++++++++++++++++------------- _pkgdown.yml | 7 +++++++ man/TealData.Rd | 2 +- man/tdata.Rd | 12 +++++++++--- 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/R/TealData.R b/R/TealData.R index 502f5684a..3ab5e2ee1 100644 --- a/R/TealData.R +++ b/R/TealData.R @@ -194,7 +194,7 @@ TealData <- R6::R6Class( # nolint }, #' @description - #' returns the tdata object. + #' returns the `tdata` object. #' #' @return (`tdata`) object of the datasets. get_tdata = function() { diff --git a/R/tdata.R b/R/tdata.R index 2b89a0671..bd1db3e78 100644 --- a/R/tdata.R +++ b/R/tdata.R @@ -19,22 +19,27 @@ #' datasets. #' @param metadata A `named list` each element contains a list of metadata about the named data.frame #' Each element of these list should be atomic and length one. +#' @param check (`logical`) value whether reproducibility check is requested or not. +#' @param label named (`list`) of datasets labels. +#' #' @return A `tdata` object #' @examples #' #' data <- new_tdata( -#' data = list(iris = iris, mtcars = reactive(mtcars), dd = data.frame(x = 1:10)), +#' data = list(iris = iris, mtcars = reactive(mtcars), ds1 = data.frame(x = 1:10)), #' code = "iris <- iris #' mtcars <- mtcars #' dd <- data.frame(x = 1:10)", -#' metadata = list(dd = list(author = "NEST"), iris = list(version = 1)) +#' metadata = list(ds1 = list(author = "NEST"), iris = list(version = 1)), +#' check = TRUE, +#' label = list(iris = "iris", mtcars = "mtcars", ds1 = "ds1") #' ) #' #' # Extract a data.frame #' isolate(data[["iris"]]()) #' #' # Get code -#' isolate(get_code(data)) +#' isolate(get_code_tdata(data)) #' #' # Get metadata #' get_metadata(data, "iris") @@ -71,16 +76,15 @@ new_tdata <- function(data, code = "", join_keys = NULL, metadata = NULL, check } } - - # code - # code <- if (is.reactive(code) && is.character(code())) { - # CodeClass$new(code()) - # } else if (is.character(code)) { - # CodeClass$new(code) - # } + # code #nolint + # code <- if (is.reactive(code) && is.character(code())) { #nolint + # CodeClass$new(code()) #nolint + # } else if (is.character(code)) { #nolint + # CodeClass$new(code) #nolint + # } #nolint # set attributes - attr(data, "code") <- code + attr(data, "code") <- if (is.reactive(code)) code else reactive(code) attr(data, "join_keys") <- join_keys attr(data, "metadata") <- metadata attr(data, "check") <- check @@ -118,7 +122,7 @@ tdata2env <- function(data) { # nolint #' @export get_code.tdata <- function(x, ...) { # nolint # note teal.data which teal depends on defines the get_code method - attr(x, "code")() # $get_code() + attr(x, "code")() } @@ -131,7 +135,7 @@ get_code.tdata <- function(x, ...) { # nolint #' @export get_code_tdata <- function(data) { checkmate::assert_class(data, "tdata") - get_code(data) + get_code.tdata(data) } diff --git a/_pkgdown.yml b/_pkgdown.yml index 95e2cc07d..bbf2ff040 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -118,3 +118,10 @@ reference: - TealDataConnector - TealDataset - TealDatasetConnector + - title: Functions for module developers + contents: + - tdata + - get_code_tdata + - get_join_keys + - get_metadata + - tdata2env diff --git a/man/TealData.Rd b/man/TealData.Rd index e91407dcf..39fb90fb9 100644 --- a/man/TealData.Rd +++ b/man/TealData.Rd @@ -236,7 +236,7 @@ named (\code{list}) of the parents of all datasets. \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-TealData-get_tdata}{}}} \subsection{Method \code{get_tdata()}}{ -returns the tdata object. +returns the \code{tdata} object. \subsection{Usage}{ \if{html}{\out{
}}\preformatted{TealData$get_tdata()}\if{html}{\out{
}} } diff --git a/man/tdata.Rd b/man/tdata.Rd index 786c3accb..63c33f24e 100644 --- a/man/tdata.Rd +++ b/man/tdata.Rd @@ -33,6 +33,10 @@ datasets.} \item{metadata}{A \verb{named list} each element contains a list of metadata about the named data.frame Each element of these list should be atomic and length one.} +\item{check}{(\code{logical}) value whether reproducibility check is requested or not.} + +\item{label}{named (\code{list}) of datasets labels.} + \item{x}{a \code{tdata} object} \item{...}{additional arguments for the generic} @@ -52,18 +56,20 @@ Create a new object called \code{tdata} which contains \code{data}, a \code{reac \examples{ data <- new_tdata( - data = list(iris = iris, mtcars = reactive(mtcars), dd = data.frame(x = 1:10)), + data = list(iris = iris, mtcars = reactive(mtcars), ds1 = data.frame(x = 1:10)), code = "iris <- iris mtcars <- mtcars dd <- data.frame(x = 1:10)", - metadata = list(dd = list(author = "NEST"), iris = list(version = 1)) + metadata = list(ds1 = list(author = "NEST"), iris = list(version = 1)), + check = TRUE, + label = list(iris = "iris", mtcars = "mtcars", ds1 = "ds1") ) # Extract a data.frame isolate(data[["iris"]]()) # Get code -isolate(get_code(data)) +isolate(get_code_tdata(data)) # Get metadata get_metadata(data, "iris")