I have a matrix that has 20 rows and 51 columns. I would like to print this data to a plain text file. I would like the elements (which are floating point numbers) in each row to be separated by spaces, and for there to be a newline at the end of every row.
I have tried using the MASS package (write.matrix), and while it appears to the naked eye to be doing the correct thing, when I try to parse the file with a perl script, doing a simple split on white space does not generate an array of 51 elements (but rather smaller ones), so clearly the elements are not space separated.
I am super new to R, and while I have decent stats skills, I seem to suck at the data presentation side.
Thanks.
How about
write.table(mtcars, file = "mtcars.txt", sep = " ")?Or something like this:
and then:
and you may want to leave
row.namesandcol.namesasTRUE(default), to keep row and column names, accordingly.