| simPregSamp | R Documentation |
Generates a sample of pregnancy outcomes from the proportions produced by
simPregProp().
simPregSamp(df, n, expand = FALSE)
df |
A data frame with class |
n |
Number of pregnancies to sample. Must be a positive integer. |
expand |
Logical value indicating whether to expand the sampled
counts into one row per pregnancy. Defaults to |
A data frame with class data.frame containing the sampled
pregnancy outcomes and their frequencies. The returned data frame retains
the columns of df and includes an additional Freq column containing
the number of sampled pregnancies for each gestational age, exposure
timing, and outcome combination.
If expand = TRUE, rows are expanded so that each row represents one
pregnancy, and Freq is set to 1.
# Generate pregnancy outcome proportions
data.prop <- simPregProp()
# Sample 1000 pregnancies
data.samp <- simPregSamp(data.prop, 1000)
head(data.samp)
# Expand to one row per pregnancy
data.samp <- simPregSamp(data.prop, 1000, expand = TRUE)
head(data.samp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.