setLabelToFactorLevels: set label to qualitative variable into a data.frame based on...

Description Usage Arguments Value Examples

View source: R/statistic_functions.R

Description

manage the conversion and sat label to qualitative into a data.frame based on dictionnary.

Usage

1
2
3
4
5
6
7
8
setLabelToFactorLevels(
  data,
  factorLevelsLabel,
  varIndex = 1,
  levelsIndex = 2,
  labelIndex = 3,
  levelsThreesholdCheck = 5
)

Arguments

data

a data.frame containing qualitative variable witch need to be labelised.

factorLevelsLabel

a data.frame containing variable names / modality as digit / label of the modality.

varIndex

a numeric vector of length one, containing the index of the variable column.

levelsIndex

a numeric vector of length one, dontaining the index of the levels column.

labelIndex

a numeric vector of length one, containing the index of the labels column.

levelsThreesholdCheck

a numeric vector of length one, containing the disctinct number value threeshold to check to evaluate if all factor variable are listed in the factorLevelsLabel table

Value

a data.frame with qualitative variable in the factorLevelsLabel convert as factor with clean label

Examples

1
2
3
4
5
6
data <- data.frame(X1 = c(0, 1, 2, 1, 2, 1, 2),
X2 = c(0, 1, 0, 1, 1, 0, 0))
labelTable <- data.frame(VARIABLE = c("X2", "X2"),
                         MODALITY = c(0, 1),
                         LABEL = c("Male", "Female"))
data <- setLabelToFactorLevels(data, labelTable)

rgriffier/statsBordeaux documentation built on Aug. 11, 2021, 9:59 a.m.