calculate_trimesters | R Documentation |
calculate_trimesters
calculates dates for pregnancy trimesters and if the birth was pre-term.
calculate_trimesters(
data,
dob,
gestation,
avg_pregnancy = 40,
avg_tri = 13,
buffer = 0
)
data |
A data object. |
dob |
The column name for date of birth. |
gestation |
The column name containing the numeric weeks of gestation (optional). |
avg_pregnancy |
Integer value for the expected number of weeks in an average pregnancy (default: 40). |
avg_tri |
Integer value for the expected length of each trimester (default: 13 weeks). |
buffer |
Integer value. Will extend the date of first trimester. Useful when you want to keep average pregnancy the same but want to include a higher maximum of pregnancies (i.e. longer third trimester). |
Uses the date of birth (required field) and any available information on the gestation time (in weeks)
to calculate the start and end of the trimesters, in separate columns, along with a flag for a suspected preterm birth.
If no gestation information is provided, the default average pregnancy length of 40 weeks is used. One can extend the length
of pregnancy by adjusting avg_pregnancy
but it is advised to use buffer
to extend the start date of the first trimester instead.
The average length of each trimester can also be adjusted from the default of 13 weeks; again, it is advised to leave this at the accepted default.
A new dataset with the start and end dates of trimesters and whether or not the birth is suspected as pre-term.
tempData <- data.frame(date_of_birth = as.Date(c('1991-01-01', '1990-02-04', '1992-01-21')), gestation = c(35, 41, NA))
calculate_trimesters(tempData, date_of_birth, gestation)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.