reOrder: Re-order levels of a factor, according to some desired...

Description Usage Arguments Author(s) Examples

View source: R/utils.R View source: R/discretize.R

Description

Use to order the levels of a factor in a desired sequence.

Usage

1
    reOrder(dataset, colName, levelNames)

Arguments

dataset

Dataset to reorder.

colName

Column name.

levelNames

Names of the reordered levels

Author(s)

Norm Matloff <matloff@cs.ucdavis.edu>, Vincent Yang <vinyang@ucdavis.edu>, and Harrison Nguyen <hhnguy@ucdavis.edu>

Examples

1
2
3
4
5
6
7
8
   sl <- c('primary','college','hs','middle','hs')
   z <- data.frame(
          schlvl = factor(x=sl,
             levels=c('college','hs','middle','primary'))
          )
   z
   z <- reOrder(z,'schlvl',c('primary','middle','hs','college'))
   str(z)  # shows the desired label order in the 'categoryorder' attribute

cdparcoord documentation built on Aug. 5, 2019, 1:02 a.m.