diff --git a/R/data.R b/R/data.R index 08a2928..6b03d62 100644 --- a/R/data.R +++ b/R/data.R @@ -5,6 +5,13 @@ #' @source \url{https://github.com/pharmaverse/admiral.test/blob/main/data/admiral_ae.rda} "ae" +#' Ophthalmology Adverse Events Dataset +#' +#' An example Adverse Events SDTM dataset with ophthalmology-specific variable `AELAT` +#' +#' @source Constructed using `ae` from the `{pharmaversesdtm}` package # nolint +"ae_ophtha" + #' Concomitant Medication Dataset #' #' A SDTM CM dataset from the CDISC pilot project diff --git a/data-raw/ae.R b/data-raw/ae.R index a098453..fb1433f 100644 --- a/data-raw/ae.R +++ b/data-raw/ae.R @@ -1,32 +1,14 @@ -# Update AE by adding AELAT variable for admiraloptha package - +# from CDISC pilot study ---- library(dplyr) -library(admiral) library(metatools) library(haven) +library(admiral) raw_ae <- read_xpt("https://github.com/cdisc-org/sdtm-adam-pilot-project/blob/master/updated-pilot-submission-package/900172/m5/datasets/cdiscpilot01/tabulations/sdtm/ae.xpt?raw=true") # nolint raw_suppae <- read_xpt("https://github.com/cdisc-org/sdtm-adam-pilot-project/blob/master/updated-pilot-submission-package/900172/m5/datasets/cdiscpilot01/tabulations/sdtm/suppae.xpt?raw=true") # nolint ae <- convert_blanks_to_na(raw_ae) suppae <- convert_blanks_to_na(raw_suppae) -# create possible AELAT values - as collected on CRF ---- -lat <- c("LEFT", "RIGHT", "BOTH") - -# create AELAT variable ---- -# with random assignment of lat values where AESOC is "EYE DISORDERS" -# Set seed so that result stays the same for each run -set.seed(1) -ae$AELAT <- if_else(ae$AESOC == "EYE DISORDERS", - apply(ae, 1, function(x) sample(lat, 1)), - NA_character_ -) -admiral_ae <- ae %>% - add_labels(AELAT = "Laterality") - -attr(admiral_ae, "label") <- "Adverse Events" - # Save dataset ---- -ae <- admiral_ae save(ae, file = "data/ae.rda", compress = "bzip2") usethis::use_data(suppae, overwrite = TRUE) diff --git a/data-raw/ae_ophtha.R b/data-raw/ae_ophtha.R new file mode 100644 index 0000000..c7ddd90 --- /dev/null +++ b/data-raw/ae_ophtha.R @@ -0,0 +1,30 @@ +# Update AE by adding AELAT variable for admiralophtha package +library(dplyr) +library(admiral) +library(metatools) +library(haven) + +# Start from standard AE dataset from this package - this should be +# in the environment already if devtools::load_all() has been run +ae_ophtha <- ae + +# create possible AELAT values - as collected on CRF ---- +lat <- c("LEFT", "RIGHT", "BOTH") + +# create AELAT variable ---- +# with random assignment of lat values where AESOC is "EYE DISORDERS" +# Set seed so that result stays the same for each run +set.seed(1) + +ae_ophtha$AELAT <- if_else(ae_ophtha$AESOC == "EYE DISORDERS", + apply(ae_ophtha, 1, function(x) sample(lat, 1)), + NA_character_ +) + +ae_ophtha <- ae_ophtha %>% + add_labels(AELAT = "Laterality") + +attr(ae_ophtha, "label") <- "Adverse Events" + +# Save dataset ---- +save(ae_ophtha, file = "data/ae_ophtha.rda", compress = "bzip2") diff --git a/data/ae.rda b/data/ae.rda index ff26beb..359f582 100644 Binary files a/data/ae.rda and b/data/ae.rda differ diff --git a/data/ae_ophtha.rda b/data/ae_ophtha.rda new file mode 100644 index 0000000..f40b42b Binary files /dev/null and b/data/ae_ophtha.rda differ diff --git a/data/suppae.rda b/data/suppae.rda index 3161038..e26bce6 100644 Binary files a/data/suppae.rda and b/data/suppae.rda differ diff --git a/inst/WORDLIST b/inst/WORDLIST index a136f89..9f6a527 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,6 +1,7 @@ ADEG ADaM AE +AELAT Arancibia CDISC Changelog @@ -34,6 +35,7 @@ SV TAs USUBJIDs VFQ +ae admiraldata admiraltemplate admiralxxx diff --git a/man/ae.Rd b/man/ae.Rd index c5bfbb7..3231c07 100644 --- a/man/ae.Rd +++ b/man/ae.Rd @@ -5,7 +5,7 @@ \alias{ae} \title{Adverse Events Dataset-updated} \format{ -An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 1191 rows and 36 columns. +An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 1191 rows and 35 columns. } \source{ \url{https://github.com/pharmaverse/admiral.test/blob/main/data/admiral_ae.rda} diff --git a/man/ae_ophtha.Rd b/man/ae_ophtha.Rd new file mode 100644 index 0000000..28d8050 --- /dev/null +++ b/man/ae_ophtha.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{ae_ophtha} +\alias{ae_ophtha} +\title{Ophthalmology Adverse Events Dataset} +\format{ +An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 1191 rows and 36 columns. +} +\source{ +Constructed using `ae` from the `{pharmaversesdtm}` package # nolint +} +\usage{ +ae_ophtha +} +\description{ +An example Adverse Events SDTM dataset with ophthalmology-specific variable `AELAT` +} +\keyword{datasets}