[R] Data transformation

Lisa lisajca at gmail.com
Mon Jan 25 23:39:32 CET 2010


Dear all,

I  have a dataset that looks like this:

x <- read.table(textConnection("col1 col2 
3 1 
2 2 
4 7 
8 6 
5 10"), header=TRUE) 

I want to rewrite it as below:

var1 var2 var3 var4 var5 var6 var7 var8 var9 var10
    1     0     1      0     0     0     0     0      0      0
    0     2     0      0     0     0     0     0      0      0
    0     0     0      1     0     0     1     0      0      0
    0     0     0      0     0     1     0     1      0      0
    0     0     0      0     1     0     0     0      0      1

Can anybody please help how to get this done? Your help would be greatly
appreciated. 

Lisa 

-- 
View this message in context: http://n4.nabble.com/Data-transformation-tp1289899p1289899.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list