-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Corrected code for data-raw/create_admiral_*.R functions. But throws errors. * Delete data-backup directory * chore: #2526 remove old admiral adlb script; push up newly run data * chore: #2526 rename file to be explicit in what it is doing; reran queries code and some fun things were found!! /s --------- Co-authored-by: Ben Straub <[email protected]>
- Loading branch information
1 parent
ed25276
commit b44fd3d
Showing
11 changed files
with
37 additions
and
624 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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,78 +1,23 @@ | ||
# Create dataset: data/admiral_adsl.rda | ||
# This script: create_admiral_adsl.R creates dataset data/admiral_adsl.rda. | ||
# This script, create_admiral_adsl.R, creates dataset data/admiral_adsl.rda. | ||
# | ||
|
||
# Preliminary | ||
library(diffdf) # nolint | ||
# Create dataset data/admiral_adsl.rda | ||
|
||
# Run template script to create adsl | ||
source("inst/templates/ad_adsl.R", echo = TRUE) # nolint | ||
|
||
# nolint start: object_name_linter. | ||
# To clarify directories (can be removed) | ||
CACHE_DIR <- "~/.cache/R/admiral_templates_data/" | ||
DATA_DIR <- "data-dir" | ||
DATA_RAW <- "data-raw" | ||
TEMPLATE_DIR <- "inst/templates/" | ||
admiral_adsl <- adsl # use correct name | ||
|
||
# clean CACHE_DIR | ||
THE_FILE <- paste0(CACHE_DIR, "/adlb.rda") | ||
THE_FILE <- paste0(CACHE_DIR, "/adsl.rda") | ||
if (file.exists(THE_FILE)) file.remove(THE_FILE) | ||
# nolint end | ||
|
||
# | ||
# STEPS | ||
# | ||
# First, use 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 USUBJID | ||
|
||
# OMIT -- orignal method - OMIT | ||
if (FALSE) { | ||
# ### original mehtod (method 1) | ||
# # 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, source the script and save data in .cache | ||
source("data-raw/admiral_adlb.R") # nolint | ||
load("~/.cache/R/admiral_templates_data/adlb.rda") | ||
} | ||
|
||
# | ||
# | ||
# Instead, USE template, as recommened by Buzz | ||
# | ||
source(paste0(TEMPLATE_DIR, "/ad_adsl.R")) # nolint | ||
load(paste0(CACHE_DIR, "adsl.rda")) | ||
admiral_adsl <- adsl | ||
|
||
# | ||
# Finally, save reduced ds | ||
# | ||
use_data(admiral_adsl, overwrite = TRUE) | ||
|
||
# | ||
# TEST - is dataset identical to .... backup of unaltered dataset | ||
# | ||
e1 <- new.env() | ||
e2 <- new.env() | ||
load("data/admiral_adsl.rda", e1) | ||
|
||
# CHANGE to YOUR location of original dataset | ||
load("data-backup/admiral_adsl.rda", e2) | ||
# Get previous dataset for comparison | ||
adsl_old <- admiral::admiral_adsl | ||
|
||
# Finally, save reduced dataset | ||
usethis::use_data(admiral_adsl, overwrite = TRUE) | ||
|
||
identical(e1$admiral_adsl, e2$admiral_adsl) | ||
diffdf(compare = e1$admiral_adsl, base = e2$admiral_adsl, keys = c("STUDYID", "USUBJID")) | ||
capture.output( | ||
diffdf( | ||
compare = e1$admiral_adsl, base = e2$admiral_adsl, | ||
keys = c("STUDYID", "USUBJID") | ||
), | ||
file = "data-raw/diffdf_23SEPT" | ||
# Compare with previous version | ||
diffdf::diffdf( | ||
base = adsl_old, | ||
compare = admiral_adsl, | ||
keys = c("STUDYID", "USUBJID") | ||
) |
File renamed without changes.
File renamed without changes.
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
Binary file not shown.
Binary file not shown.
Binary file not shown.