diff --git a/data-raw/create_admiral_adlb.R b/data-raw/create_admiral_adlb.R index 0ce259098..cdd1cfd4c 100644 --- a/data-raw/create_admiral_adlb.R +++ b/data-raw/create_admiral_adlb.R @@ -2,7 +2,7 @@ # This is a MULTI-step process. -# First, using template to create the R script (in data-raw/admiral_adlb.R) which will generate the data. +# First, using template to create the R script (in data-raw/admiral_adlb.R). # Next, source this script and create the data (~/.cache/R/admiral_template_data/admiral_adlb.rda) # Finally, shorten this data (now ~ 1.2 MB) by selecting only certain USERJID @@ -19,41 +19,60 @@ use_ad_template( ) # Second, source the script and save data in .cache -source("data-raw/admiral_adlb.R") # nolint +source("data-raw/admiral_adlb.R") # nolint # Load the data into .GlobalEnv -load("~/.cache/R/admiral_templates_data/adlb.rda" ) +load("~/.cache/R/admiral_templates_data/adlb.rda") -#nrow(adlb) 83,652 +# nrow(adlb) 83,652 # limit rows, by selecting only these USUBJID #' 01-701-1015, 01-701-1023, 01-701-1028, 01-701-1033, #' 01-701-1034, 01-701-1047, 01-701-1097, 01-705-1186, #' 01-705-1292, 01-705-1310, 01-708-1286 -USUBJID = -c("01-701-1015", -"01-701-1023", -"01-701-1028", -"01-701-1033", -"01-701-1034", -"01-701-1047", -"01-701-1097", -"01-705-1186", -"01-705-1292", -"01-705-1310", -"01-708-1286" -) +usubjid <- + c( + "01-701-1015", + "01-701-1023", + "01-701-1028", + "01-701-1033", + "01-701-1034", + "01-701-1047", + "01-701-1097", + "01-705-1186", + "01-705-1292", + "01-705-1310", + "01-708-1286" + ) # prepare for inner join -user = tibble( - USUBJID = USUBJID) +user <- tibble( + USUBJID = usubjid +) -result = inner_join(adlb,user) -admiral_adlb = result +result <- inner_join(adlb, user) +admiral_adlb <- result # check -#USUBJID %in% result$USUBJID +# USUBJID %in% result$USUBJID -# Finally, saved reduced ds +# Finally, save reduced ds use_data(admiral_adlb, overwrite = TRUE) + +## +## TEST - is dataset identical to .... backup of unaltered dataset +## +e1 = new.env() +e2 = new.env() + +load("data/admiral_adlb.rda", e1) + +# CHANGE to your location of original dataset +load("data-backup/admiral_adlb.rda", e2) + +identical(e1$admiral_adsl, e2$admiral_adsl) + +# cleanup +rm(e1) +rm(e2)