diff --git a/.Rbuildignore b/.Rbuildignore index ab8c8fb..97b2c89 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -17,3 +17,4 @@ ^staged_dependencies.yaml$ ^README.Rmd$ ^\.devcontainer$ +^data-raw$ diff --git a/.lintr b/.lintr index e3e6a1e..6f19a35 100644 --- a/.lintr +++ b/.lintr @@ -9,5 +9,6 @@ linters: linters_with_defaults( exclusions: list( "R/data.R" = Inf, "inst" = list(undesirable_function_linter = Inf), - "vignettes" = list(undesirable_function_linter = Inf) + "vignettes" = list(undesirable_function_linter = Inf), + "data-raw" = list(undesirable_function_linter = Inf) ) diff --git a/DESCRIPTION b/DESCRIPTION index 1aafbc7..503b19e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -40,7 +40,8 @@ Suggests: pharmaversesdtm (>= 1.0.0), rmarkdown, testthat (>= 3.0.0), - tibble + tibble, + usethis (>= 2.2.3) VignetteBuilder: knitr Config/testthat/edition: 3 diff --git a/R/data.R b/R/data.R index e69de29..474d380 100644 --- a/R/data.R +++ b/R/data.R @@ -0,0 +1,6 @@ +#' Example demographic dataset +#' +#' An example Demographic SDTM dataset for metabolic studies. +#' +#' @source Constructed using `dm` from the `{pharmaversesdtm}` package +"dm_metabolic" diff --git a/data-raw/dm_metabolic.R b/data-raw/dm_metabolic.R new file mode 100644 index 0000000..2d7f3a8 --- /dev/null +++ b/data-raw/dm_metabolic.R @@ -0,0 +1,46 @@ +# Dataset: dm_metabolic +# Description: Demographics (DM) SDTM dataset for metabolic studies + +# Load libraries ---- +library(pharmaversesdtm) +library(tibble) +library(dplyr) +library(purrr) + +# Import DM data from `pharmaversesdtm` ---- +data("dm") + +# Subset to first 5 subjects ---- +dm_subset <- dm |> + filter(USUBJID %in% c( + "01-701-1015", "01-701-1023", "01-701-1028", + "01-701-1033", "01-701-1034" + )) + +# Change treatment arms ---- +dm_metabolic <- dm_subset |> + mutate( + ARMCD = case_when( + ARMCD == "Pbo" ~ "Pbo", + ARMCD %in% c("Xan_Hi", "Xan_Lo") ~ "Ins" + ), + ARM = case_when( + ARM == "Placebo" ~ "Placebo", + ARM %in% c( + "Xanomeline High Dose", + "Xanomeline Low Dose" + ) ~ "Insulin" + ), + ACTARMCD = ARMCD, + ACTARM = ARM + ) + +# Restore attributes ---- +common_cols <- intersect(names(dm_metabolic), names(dm)) +walk( + .x = common_cols, + .f = \(x) attr(dm_metabolic[[x]], "label") <<- attr(dm[[x]], "label") +) + +# Save data inside data folder---- +usethis::use_data(dm_metabolic, overwrite = TRUE) diff --git a/data/dm_metabolic.rda b/data/dm_metabolic.rda new file mode 100644 index 0000000..296e6c7 Binary files /dev/null and b/data/dm_metabolic.rda differ diff --git a/man/dm_metabolic.Rd b/man/dm_metabolic.Rd new file mode 100644 index 0000000..302e6da --- /dev/null +++ b/man/dm_metabolic.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{dm_metabolic} +\alias{dm_metabolic} +\title{Example demographic dataset} +\format{ +An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 5 rows and 25 columns. +} +\source{ +Constructed using \code{dm} from the \code{{pharmaversesdtm}} package +} +\usage{ +dm_metabolic +} +\description{ +An example Demographic SDTM dataset for metabolic studies. +} +\keyword{datasets}