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

Closes #12 - Created DM metabolic dataset #20

Merged
merged 7 commits into from
Jul 30, 2024
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
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
^staged_dependencies.yaml$
^README.Rmd$
^\.devcontainer$
^data-raw$
3 changes: 2 additions & 1 deletion .lintr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -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"
46 changes: 46 additions & 0 deletions data-raw/dm_metabolic.R
Original file line number Diff line number Diff line change
@@ -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)
Binary file added data/dm_metabolic.rda
Binary file not shown.
19 changes: 19 additions & 0 deletions man/dm_metabolic.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading