[R] How to generate a new factor variable by two other factor variables

Shuguang Sun shuguang at gmail.com
Tue Nov 4 16:29:17 CET 2008


How to generate a new factor variable by two other factor variables?

For example, if I have two factor variables, factorA and factorB,
factorA factorB
    0       0
    0       0
    1       0
    0       1
    1       1

Is there a simple way to generate a new 4-levels factor variable as

factorC factorA factorB
    0      0       0
    0      0       0
    1      1       0
    2      0       1
    3      1       1

--
Shuguang Sun
Fudan University, China



More information about the R-help mailing list