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

2009-09-19 Thread Xi Ang
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

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

2009-09-19 Thread David Winsemius
XYT - array(1:150, dim=c(3,5,10)) XYbyT= matrix(apply(XYT, 3, I), ncol=10) ...or even... XYbyT= matrix(XYT, ncol=10) -- David. On Sep 19, 2009, at 1:11 PM, Xi Ang wrote: Hi I have some data with these dimensions: 5 3 100 which correspond to the x, y, and time dimensions, for a

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

2009-09-19 Thread Xi Ang
Thanks for your reply. Is there a way I can save the data to an ascii file without losing the row/column structure? I have tried save(...) and write.table(...) but the output file seems to jumble up the order of the matrix. Thanks Xi David Winsemius wrote: XYT - array(1:150,

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

2009-09-19 Thread David Winsemius
?cat ?apply ?t You could follow each row of the transposed matrix with a newline: apply(t(XYbyT), 1, function(x) cat(x, \n, file=output.txt, append=TRUE) ) On Sep 19, 2009, at 8:11 PM, Xi Ang wrote: Thanks for your reply. Is there a way I can save the data to an ascii file without

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

2009-09-19 Thread David Winsemius
Another possiblity: write.table( t(XYbyT), file=outcsv.csv, sep=\t) On Sep 19, 2009, at 9:16 PM, David Winsemius wrote: ?cat ?apply ?t You could follow each row of the transposed matrix with a newline: apply(t(XYbyT), 1, function(x) cat(x, \n, file=output.txt, append=TRUE) ) On Sep

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

2009-09-19 Thread Gabor Grothendieck
If the only reason you want to save it is to later read it back into R later then see ?dump or even ?save On Sat, Sep 19, 2009 at 8:11 PM, Xi Ang slideprojec...@gmail.com wrote: Thanks for your reply. Is there a way I can save the data to an ascii file without losing the row/column