levIndex {wrMisc}R Documentation

Transform (factor) levels into index

Description

This function helps transforming a numeric or character vector into indexes of levels (of its original values). By default indexes are assigned by order of occurance, ie, the first value of x will be get the index of 1. Using the argument byOccurance=FALSE the resultant indexes will follow the sorted values.

Usage

levIndex(
  dat,
  byOccurance = TRUE,
  silent = FALSE,
  debug = FALSE,
  callFrom = NULL
)

Arguments

dat

(numeric or character vector or factor) main input

byOccurance

(logical) toogle if lowest index should be based on alphabetical order or on order of input

silent

(logical) suppress messages

debug

(logical) additional messages for debugging

callFrom

(character) allow easier tracking of messages produced

Value

matrix with mean values

See Also

rowSds, colSums

Examples

x1 <- letters[rep(c(5,2:3),1:3)]
levIndex(x1)
levIndex(x1, byOccurance=FALSE)
## with factor 
fa1 <- factor(letters[rep(c(5,2:3),1:3)], levels=letters[1:6])
levIndex(fa1)
levIndex(fa1, byOccurance=FALSE)

[Package wrMisc version 1.15.1 Index]