ff_mode: Return the most frequent level in a factor

View source: R/ff_newdata.R

ff_modeR Documentation

Return the most frequent level in a factor

Description

When producing conditional estimates from a regression model, it is often useful to set variables not of interest to their mode when creating the newdata object.

Usage

ff_mode(...)

finalfit_mode(...)

Arguments

...

Unquoted factor names.

Value

The most frequent level in a factor.

See Also

summary_df ff_expand

Examples

library(dplyr)
colon_s %>% 
  summarise(age.factor = ff_mode(age.factor))
  
colon_s %>% 
  select(sex.factor, rx.factor, obstruct.factor, perfor.factor) %>% 
  summarise(across(everything(), ff_mode))
  
colon_s %>% 
  reframe(across(where(is.factor), ff_mode))
  # Note, 4 rows is returned in this example because 4 factor levels within `hospital` 
  # have the same frequency. 

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