Skip to content

Commit

Permalink
Merge pull request #87 from pharmaverse/85_resolve_bug_duplicate_reco…
Browse files Browse the repository at this point in the history
…rds_in_SV_for_USUBIJD_and_VISIT

#82 Resolve Bug: Duplicate observation for group USUBJID and VISIT
  • Loading branch information
manciniedoardo authored Feb 26, 2024
2 parents f901b2a + 97ecbc5 commit f98b7dc
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 13 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ URL: https://pharmaverse.github.io/pharmaversesdtm/main/, https://github.com/pha
Depends: R (>= 3.5.0)
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Suggests:
devtools,
lintr,
Expand Down
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
20 changes: 20 additions & 0 deletions data-raw/sv.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,29 @@
# Load libraries -----
library(haven)
library(admiral)
library(dplyr)
library(metatools)
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) %>%
add_labels(
VISIT = "Visit Name",
VISITNUM = "Visit Number"
)


# Label dataset ----
attr(sv, "label") <- "Subject Visits"

Expand Down
Binary file modified data/sv.rda
Binary file not shown.
4 changes: 2 additions & 2 deletions man/ae_ophtha.Rd

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

4 changes: 2 additions & 2 deletions man/ex_ophtha.Rd

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

10 changes: 5 additions & 5 deletions man/get_terms.Rd

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

2 changes: 1 addition & 1 deletion man/qs_ophtha.Rd

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

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 f98b7dc

Please sign in to comment.