ff_expand: Summarise with mode and mean/median and expand given factors

ff_expandR Documentation

Summarise with mode and mean/median and expand given factors

Description

When producing conditional estimates from a regression model, it is often useful to set variables not of interest to their mode for factors and mean or median for numerics when creating the newdata object, and combine these with all levels for factors of interest.

Usage

ff_expand(.data, ..., cont = "mean")

finalfit_expand(.data, ..., cont = "mean")

Arguments

.data

A data frame or tibble.

...

Factors to expand.

cont

One of "mean" or "median": the summary estimate for continuous variables.

Value

A data frame or tibble with the mode for factors and mean/median for continuous variables, with given factors expanded to include all levels.

See Also

ff_mode summary_df

Examples

library(dplyr)
colon_s %>% 
select(-hospital) %>% 
ff_expand(age.factor, sex.factor)

finalfit documentation built on Sept. 11, 2024, 9:01 p.m.