[R-pkgs] New package: lfactors (0.4-0)

Bailey, Paul pbailey at air.org
Tue Apr 28 21:43:15 CEST 2015


Dear R users,

The "lfactors" package is now available from CRAN. It provides a class "lfactor" that is similar to the class "factor" but can be referred to by level or label.

This package is best explained with an example

flips <- lfactor(c(0,1,1,0,0,1), levels=0:1, labels=c("Tails", "Heads"))
# Tails can now be referred to as, "Tails" or 0
# These two lines return the same result
flips == "Tails"
flips == 0

Other functions, such as %in% and != also work with lfactors.

This package is helpful for data that was labeled with long labels, making references to the label cumbersome. This happens to me when I'm sharing data with users of other statistical software that uses the same convention as lfactors--that is, allowing a factor level to be referred to by its numeric or character value.

Comments, contributions, and suggests are welcome.

Best,
Paul
---
Paul D. Bailey, Ph.D.
Economist, Education
American Institutes for Research
202.403.5694



More information about the R-packages mailing list