[R] data formatting: from rows to columns

Federico Calboli f.calboli at imperial.ac.uk
Tue Aug 28 20:17:56 CEST 2007


Hi All,

I have some data I need to write as a file from R to use in a different program. 
My data comes as a numeric matrix of n rows and 2 colums, I need to transform 
each row as a two rows 1 col output, and separate the output of each row with a 
blanck line.

Foe instance I need to go from this:

          V2  V3
27  2032567  19
28  2035482  19
126 2472826  19
132 2473320  19
136 2035480 135
145 2062458 135
148 2074927 135
151 2102395 142
156 2027252 142
158 2473082 142

to

2032567
19

2035482
19

2472826
19

2473320
19

2035480
135

...

Any hint? I seem a bit stuck. cat(unlist(data), file ='data.txt', sep = '\n') 
(obviously) does not work...

Cheers,

Fede






-- 
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St Mary's Campus
Norfolk Place, London W2 1PG

Tel  +44 (0)20 7594 1602     Fax (+44) 020 7594 3193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com



More information about the R-help mailing list