Skip to contents

Generate a new table containing classified columns from continuous variables according to the grouping interval list provided by the user

Usage

mutate_class(data, breaks_list, sp_column, openr = FALSE, digits = 0)

Arguments

data

a dataframe contain continuous type data column.

breaks_list

data split points for grouping such as c(18,30,40,50,60,70,Inf).

sp_column

the specified column name adapted to breaks_list,using a non-standard normal form.

openr

default openright= FALSE,the data interval is in the form of left opening and right closing,such as [1,2).When openright= TRUE, the data interval is in the form of left closing and right opening.

digits

defines the number of decimal places for the return label.

Value

add a user-specified classified data column to the dataframe.

Details

It is suitable for the interval segmentation of continuous data such as patient age and some biochemical indexes.

Examples

if (FALSE) {
data(data_med)
pat = data_med$pat %>% calcu_age(.,birthdate)

breaks_age <- c(18,30,40,50,60,70,Inf)
mutate_class(pat,breaks_age,age,digits=2)
}