Learn R Programming

RODProt (version 0.2.0)

hashFactor: Create a hashFactor

Description

Creates a hashFactor object, which operates in much the same way as a factor, but doesn't require a continuous sequence of integers for the levels.

Usage

hashFactor(x = character(), levels, codes)

Arguments

x
The values to be encoded into a factor
levels
The labels associated with each level of the factor
codes
the integer codes associated with each level of the factor

Examples

Run this code
fac <- hashFactor(sample(LETTERS[1:5], 10, replace=TRUE),
	levels=LETTERS[1:5], codes=c(1,5,8,2,6))
d <- data.frame(i=11:20, f=fac)

Run the code above in your browser using DataLab