generated from pharmaverse/admiraltemplate
-
Notifications
You must be signed in to change notification settings - Fork 2
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
- Loading branch information
1 parent
36bb03f
commit 7b70792
Showing
9 changed files
with
61 additions
and
21 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,32 +1,14 @@ | ||
# Update AE by adding AELAT variable for admiraloptha package | ||
|
||
# from CDISC pilot study ---- | ||
library(dplyr) | ||
library(admiral) | ||
library(metatools) | ||
library(haven) | ||
library(admiral) | ||
|
||
raw_ae <- read_xpt("https://github.com/cdisc-org/sdtm-adam-pilot-project/blob/master/updated-pilot-submission-package/900172/m5/datasets/cdiscpilot01/tabulations/sdtm/ae.xpt?raw=true") # nolint | ||
raw_suppae <- read_xpt("https://github.com/cdisc-org/sdtm-adam-pilot-project/blob/master/updated-pilot-submission-package/900172/m5/datasets/cdiscpilot01/tabulations/sdtm/suppae.xpt?raw=true") # nolint | ||
ae <- convert_blanks_to_na(raw_ae) | ||
suppae <- convert_blanks_to_na(raw_suppae) | ||
|
||
# create possible AELAT values - as collected on CRF ---- | ||
lat <- c("LEFT", "RIGHT", "BOTH") | ||
|
||
# create AELAT variable ---- | ||
# with random assignment of lat values where AESOC is "EYE DISORDERS" | ||
# Set seed so that result stays the same for each run | ||
set.seed(1) | ||
ae$AELAT <- if_else(ae$AESOC == "EYE DISORDERS", | ||
apply(ae, 1, function(x) sample(lat, 1)), | ||
NA_character_ | ||
) | ||
admiral_ae <- ae %>% | ||
add_labels(AELAT = "Laterality") | ||
|
||
attr(admiral_ae, "label") <- "Adverse Events" | ||
|
||
# Save dataset ---- | ||
ae <- admiral_ae | ||
save(ae, file = "data/ae.rda", compress = "bzip2") | ||
usethis::use_data(suppae, overwrite = TRUE) |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Update AE by adding AELAT variable for admiralophtha package | ||
library(dplyr) | ||
library(admiral) | ||
library(metatools) | ||
library(haven) | ||
|
||
# Start from standard AE dataset from this package - this should be | ||
# in the environment already if devtools::load_all() has been run | ||
ae_ophtha <- ae | ||
|
||
# create possible AELAT values - as collected on CRF ---- | ||
lat <- c("LEFT", "RIGHT", "BOTH") | ||
|
||
# create AELAT variable ---- | ||
# with random assignment of lat values where AESOC is "EYE DISORDERS" | ||
# Set seed so that result stays the same for each run | ||
set.seed(1) | ||
|
||
ae_ophtha$AELAT <- if_else(ae_ophtha$AESOC == "EYE DISORDERS", | ||
apply(ae_ophtha, 1, function(x) sample(lat, 1)), | ||
NA_character_ | ||
) | ||
|
||
ae_ophtha <- ae_ophtha %>% | ||
add_labels(AELAT = "Laterality") | ||
|
||
attr(ae_ophtha, "label") <- "Adverse Events" | ||
|
||
# Save dataset ---- | ||
save(ae_ophtha, file = "data/ae_ophtha.rda", compress = "bzip2") |
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.