-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EXPERIMENT ... Generate data/admiral_adlb.rda using template, tempora…
…ry .cache storage, inner_join to reduce number of rows. NOT FINAL.
- Loading branch information
1 parent
aeaed83
commit d79b080
Showing
3 changed files
with
69 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,59 @@ | ||
# Create data/admiral_adlb.rda | ||
# Create dataset: data/admiral_adlb.rda | ||
|
||
# This is a TWO-step process. | ||
# This is a MULTI-step process. | ||
|
||
library(admiral) | ||
# First, using template to create the R script (in data-raw/admiral_adlb.R) which will generate the data. | ||
# 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 | ||
|
||
# First, generate script from template | ||
adam_name="adlb" | ||
save_path = paste0("./data-raw/admiral_", adam_name, ".R") | ||
|
||
use_ad_template(adam_name = adam_name, | ||
save_path = save_path, | ||
open = F, | ||
overwrite=T) | ||
# First, create the R script (from a template) | ||
adam_name <- "adlb" | ||
save_path <- paste0("./data-raw/admiral_", adam_name, ".R") | ||
|
||
use_ad_template( | ||
adam_name = adam_name, | ||
save_path = save_path, | ||
open = FALSE, | ||
overwrite = TRUE | ||
) | ||
|
||
# Second, run the script (manually) | ||
# Second, source the script and save data in .cache | ||
source("data-raw/admiral_adlb.R") # nolint | ||
|
||
# Load the data into .GlobalEnv | ||
load("~/.cache/R/admiral_templates_data/adlb.rda" ) | ||
|
||
#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" | ||
) | ||
|
||
# prepare for inner join | ||
user = tibble( | ||
USUBJID = USUBJID) | ||
|
||
result = inner_join(adlb,user) | ||
admiral_adlb = result | ||
|
||
# check | ||
#USUBJID %in% result$USUBJID | ||
|
||
# Finally, saved reduced ds | ||
use_data(admiral_adlb, overwrite = TRUE) |
Binary file not shown.