generate_df | R Documentation |
This function is a small utility to create a specific length dataframe
with a set number of groups, specific mean/sd per group. Note that the total length
of the dataframe will be n
* n_grps
.
generate_df(n = 10L, n_grps = 1L, mean = c(10), sd = mean/10, with_seed = NULL)
n |
An integer indicating the number of rows per group, default to |
n_grps |
An integer indicating the number of rows per group, defaults to |
mean |
A number indicating the mean of the randomly generated values, must be a vector of equal length to the |
sd |
A number indicating the standard deviation of the randomly generated values, must be a vector of equal length to the |
with_seed |
A seed to make the randomization reproducible |
a tibble/dataframe
2-19
Other Utilities:
add_text_img()
,
fa_icon_repeat()
,
fmt_pad_num()
,
fmt_pct_extra()
,
fmt_symbol_first()
,
gt_add_divider()
,
gt_badge()
,
gt_double_table()
,
gt_duplicate_column()
,
gt_fa_column()
,
gt_fa_rank_change()
,
gt_fa_rating()
,
gt_fa_repeats()
,
gt_highlight_cols()
,
gt_highlight_rows()
,
gt_img_border()
,
gt_img_circle()
,
gt_img_multi_rows()
,
gt_img_rows()
,
gt_index()
,
gt_merge_stack_color()
,
gt_merge_stack()
,
gt_two_column_layout()
,
gtsave_extra()
,
img_header()
,
pad_fn()
,
tab_style_by_grp()
library(dplyr)
generate_df(
100L,
n_grps = 5,
mean = seq(10, 50, length.out = 5)
) %>%
group_by(grp) %>%
summarise(
mean = mean(values), # mean is approx mean
sd = sd(values), # sd is approx sd
n = n(), # each grp is of length n
# showing that the sd default of mean/10 works
`mean/sd` = round(mean / sd, 1)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.