Skip to content

Commit

Permalink
#82 Resolve Bug: Duplicate observation for group USUBJID and VISIT
Browse files Browse the repository at this point in the history
  • Loading branch information
PoojaKumari05 committed Feb 12, 2024
1 parent f901b2a commit 6b66b15
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions data-raw/sv.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Binary file modified data/sv.rda
Binary file not shown.
3 changes: 2 additions & 1 deletion man/sv.Rd

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

0 comments on commit 6b66b15

Please sign in to comment.