Learn R Programming

tidyCDISC (version 0.2.2)

varN_fctr_reorder: Re-order Factor Levels by VARN

Description

Function to that looks for VARN counterparts to any character or factor VAR variables in any dataframe and re-orders there factor levels, taking the lead from VARN's numeric guide.

Usage

varN_fctr_reorder(data)

Value

The data frame after having factor levels re-ordered by VARN

Arguments

data

a dataframe, including one enriched with SAS labels attributes

Examples

Run this code
data(adae, package = "tidyCDISC")

varN_fctr_adae <- varN_fctr_reorder(adae)

unique(adae[,c("AGEGR1", "AGEGR1N")])
levels(adae$AGEGR1)
levels(varN_fctr_adae$AGEGR1)

unique(adae[,c("RACE", "RACEN")])
levels(adae$RACE)
levels(varN_fctr_adae$RACE)

Run the code above in your browser using DataLab