[R] Add columns of dataset

Lisa lisajca at gmail.com
Fri Dec 3 21:40:35 CET 2010


Dear all,

I have a dataset that looks like 

id  var1  var2  var4  var7  var8 
1    0.0   0.1    0.3    0.9    0.0    
2    0.4   0.6    0.0    0.0    0.2    
3    0.0   0.0    0.0    0.8    0.7    

Some columns are missed, for example, here the fourth (var3), sixth(var5)
and seventh (var6) columns. I want to first determine which columns are
missed in a huge dataset and then add the missed columns with the values of
zeros that looks like

id  var1  var2   var3  var4  var5  var6  var7  var8 
1    0.0   0.1     0.0    0.3   0.0    0.0   0.9    0.0    
2    0.4   0.6     0.0    0.0   0.0    0.0   0.0    0.2    
3    0.0   0.0     0.0    0.0   0.0    0.0   0.8    0.7    

Can anybody please help how to get this done? Thanks a lot in advance

Lisa

-- 
View this message in context: http://r.789695.n4.nabble.com/Add-columns-of-dataset-tp3071722p3071722.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list