diff --git a/posts/zzz_DO_NOT_EDIT_how__i__reb.../how__i__rebuilt_a__lost__ec_g__data__script_in__r.qmd b/posts/zzz_DO_NOT_EDIT_how__i__reb.../how__i__rebuilt_a__lost__ec_g__data__script_in__r.qmd index c0b17096..0fd20095 100644 --- a/posts/zzz_DO_NOT_EDIT_how__i__reb.../how__i__rebuilt_a__lost__ec_g__data__script_in__r.qmd +++ b/posts/zzz_DO_NOT_EDIT_how__i__reb.../how__i__rebuilt_a__lost__ec_g__data__script_in__r.qmd @@ -77,6 +77,19 @@ egdtc <- vs %>% rename(EGDTC = VSDTC) ``` +The output: + +``` +USUBJID VISIT EGDTC + +1 01-701-1015 SCREENING 1 2013-12-26 +2 01-701-1015 SCREENING 2 2013-12-31 +3 01-701-1015 BASELINE 2014-01-02 +4 01-701-1015 AMBUL ECG PLACEMENT 2014-01-14 +5 01-701-1015 WEEK 2 2014-01-16 +6 01-701-1015 WEEK 4 2014-01-30 +``` + ### 3. Generating a Grid of Patient Data Here, I create a grid of all possible combinations of subject IDs, test codes (e.g., `QT`, `HR`, `RR`, `ECGINT`), time points (e.g., after lying down, after standing), and visits. These combinations represent different test results collected across multiple visits. @@ -114,6 +127,18 @@ eg <- expand.grid( ) ``` +The output: + +``` + USUBJID EGTESTCD EGTPT VISIT +1 01-701-1015 QT AFTER LYING DOWN FOR 5 MINUTES SCREENING 1 +2 01-701-1015 HR AFTER LYING DOWN FOR 5 MINUTES SCREENING 1 +3 01-701-1015 RR AFTER LYING DOWN FOR 5 MINUTES SCREENING 1 +4 01-701-1015 ECGINT AFTER LYING DOWN FOR 5 MINUTES SCREENING 1 +5 01-701-1015 QT AFTER STANDING FOR 1 MINUTE SCREENING 1 +6 01-701-1015 HR AFTER STANDING FOR 1 MINUTE SCREENING 1 +``` + ### 4. Generating Random Test Results For each combination in the grid, I generate random test results using a normal distribution to simulate realistic values for each test code. To determine the means and standard deviations, I used the original EG dataset as a reference. By analyzing the range and distribution of values in the original dataset, I could extract realistic means and standard deviations for each ECG test (e.g., QT, HR, RR, ECGINT). This approach allowed me to ensure that the synthetic data aligned closely with the patterns and variability observed in the original clinical data.