[R] Create New variable

From: Marc Bernard <bernarduse1_at_yahoo.fr>
Date: Sun 11 Sep 2005 - 22:16:21 EST


Dear All,  

I want to create one numeric variable from a factor one. here is a simple example:  

x1 x2 factor
x11 x21 f1
x12 x22 f1
x13 x23 f2
x14 x24 f3
. . .
. . .
 

Suppose that the variable factor has 3 levels (f1,f2,f3). I want to add to this data frame a numeric variable x4 in (v1,v2,v3) such that x4=v1 if factor = f1, x4 = v2 if factor = f2 and x4 = v3 if factor = f3.      

Thanks a lot for any help,  

Bernard                 


        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun Sep 11 22:24:29 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:09 EST