ensure_factor {tableeasy}R Documentation

Ensure Factor Variable in Data Set

Description

Ensure that factor variables in data set are of the correct type.

Usage

ensure_factor(data, execute = FALSE, threshold_factor = 5)

Arguments

data

A data frame.

execute

Bool, default = FALSE. If TRUE, then output data frame.

threshold_factor

An integer, default = 5. Criteria to judge as factor type. When a variable has more than threshold_factor unique values, it is considered continuous.

Value

A list containing data frame and description.

Examples

## Load Mayo Clinic Primary Biliary Cirrhosis Data
library(survival)
library(tableeasy)
data(pbc)
## Check variables
head(pbc)
##
ensure_factor(pbc)

ensure_factor(pbc,execute=TRUE)[['message']]
pbc_exe <- ensure_factor(pbc,execute=TRUE)[['data']]

[Package tableeasy version 1.1.2 Index]