| calc_DY {sdtmval} | R Documentation | 
Calculate a DY variable (day of study)
Description
Utilizes the DY method from the SDTM spec: --DTC-RFSTDTC+1 if --DTC is on
or after RFSTDTC. --DTC-RFSTDTC if --DTC precedes RFSTDTC. This
function can also be used for the ENDY method from the spec which has the
same logic.
Usage
calc_DY(tbl, DY_col, DTC_col, RFSTDTC = "RFSTDTC")
Arguments
| tbl | a data frame with the date column  | 
| DY_col | string, the name of the new DY column to create | 
| DTC_col | string, the column in  | 
| RFSTDTC | a string, the column to use for  | 
Value
a modified copy of tbl with the new DY column
See Also
Examples
df <- data.frame(
  DTC = c("2023-08-01", "2023-08-02", "2023-08-03", "2023-08-04"),
  RFSTDTC = rep("2023-08-02", 4)
)
calc_DY(df, DY_col = "XXDY", DTC_col = "DTC")
[Package sdtmval version 0.4.1 Index]