diff --git a/R/data.R b/R/data.R index adf6077..4ed3459 100644 --- a/R/data.R +++ b/R/data.R @@ -218,7 +218,8 @@ #' Subject Visits Dataset #' -#' A SDTM SV dataset from the CDISC pilot project +#' A SDTM SV dataset from the CDISC pilot project. Duplicate observation for group +#' variable USUBJID and VISIT is corrected. #' #' @source \url{https://github.com/cdisc-org/sdtm-adam-pilot-project/blob/master/updated-pilot-submission-package/900172/m5/datasets/cdiscpilot01/tabulations/sdtm/sv.xpt?raw=true} # nolint "sv" diff --git a/data-raw/sv.R b/data-raw/sv.R index 3a40165..178173a 100644 --- a/data-raw/sv.R +++ b/data-raw/sv.R @@ -4,9 +4,21 @@ # Load libraries ----- library(haven) library(admiral) +library(dplyr) raw_sv <- read_xpt("https://github.com/cdisc-org/sdtm-adam-pilot-project/blob/master/updated-pilot-submission-package/900172/m5/datasets/cdiscpilot01/tabulations/sdtm/sv.xpt?raw=true") # nolint sv <- convert_blanks_to_na(raw_sv) +sv <- sv %>% + group_by(USUBJID, VISITNUM) %>% + mutate( + ASEQ = row_number(), + n=n()) %>% + mutate( + VISIT = ifelse(n > 1, paste0("UNSCHEDULED ", floor(VISITNUM), ".", ASEQ), VISIT), + VISITNUM = ifelse(n > 1, as.numeric(paste0(floor(VISITNUM), ".", ASEQ)), VISITNUM)) %>% + ungroup() %>% + select(-ASEQ,-n) + # Label dataset ---- attr(sv, "label") <- "Subject Visits" diff --git a/data/sv.rda b/data/sv.rda index c24f1cc..ff082ed 100644 Binary files a/data/sv.rda and b/data/sv.rda differ diff --git a/man/sv.Rd b/man/sv.Rd index cc9f846..c314008 100644 --- a/man/sv.Rd +++ b/man/sv.Rd @@ -14,6 +14,7 @@ An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) w sv } \description{ -A SDTM SV dataset from the CDISC pilot project +A SDTM SV dataset from the CDISC pilot project. Duplicate observation for group +variable USUBJID and VISIT is corrected. } \keyword{datasets}