div_quantile {tableeasy}R Documentation

Split a Variable by Quantile Statistics

Description

Split a continuous variable by quantile statistics. Converts a continuous variable to a categorical variable.

Usage

div_quantile(var, div, data)

Arguments

var

A string. A variable to be summarized given as a string.

div

A positive integer greater than 1 or a vector of integers. If a positive integer greater than 1, it is the number of factor levels when the variable is split by quantile statistics. If a vector of integers, it is the strategy of grouping x by quantile statistics and then merging groups.

data

A data frame in which these variables exist.

Value

A factor variable.

Examples

## Load Mayo Clinic Primary Biliary Cirrhosis Data
library(survival)
library(tableeasy)
data(pbc)
## Check variables
head(pbc)
##
div_quantile(var = 'age', div = 5, data = pbc)
div_quantile(var = 'age', div = c(2,3), data = pbc)

[Package tableeasy version 1.1.2 Index]