[R] Converting matrices into row vectors and saving as ASCII text

Xi Ang slideprojector at gmail.com
Sat Sep 19 19:11:58 CEST 2009


Hi

I have some data with these dimensions:
5 3 100

which correspond to the x, y, and time dimensions, for a variable, p.

I need the data in this format: 100 rows (1 row per time unit), and 15
values in each row. 

I have attempted to reshape my data

>dim(data)
5 3 100

>attr(data,'dim')<-c(dim(data)[3],dim(data)[1]*dimdata[2])

So I get data with 100 rows, 15 columns.

I need to use this data outside of R, and so have to save it as an ASCII
file that retains the row-column structure of the data, but I do not know
how to.

It would be ideal if I could end up with a text file that also has an
additional column that labels which time unit (1-100) the row belongs to,
i.e.

1   a1,1  a1,2 ........... a1,15
2   a2,1  a2,2 ........... a2,15
3   a3,1  a3,2 ........... a3,15
4   a4,1  a4,2 ........... a4,15
.
.
.
99
100

Any suggestions would be appreciated.

Thanks
Xi


-- 
View this message in context: http://www.nabble.com/Converting-matrices-into-row-vectors-and-saving-as-ASCII-text-tp25523562p25523562.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list