Re: [R] Hyper-elegant code to get a text file, transpose it, and write it

2008-06-05 Thread Gabor Csardi
On Thu, Jun 05, 2008 at 10:26:08AM -0200, Alberto Monteiro wrote: > > > > Uwe Ligges wrote: > > > > You probably want > > > > write.table(t(read.table(file.in)), file = file.out, row.names = > > FALSE, col.names = FALSE) > > > Ok, almost there. I forgot to tell (because I didn't know) > that

Re: [R] Hyper-elegant code to get a text file, transpose it, and write it

2008-06-05 Thread Alberto Monteiro
Uwe Ligges wrote: > > You probably want > > write.table(t(read.table(file.in)), file = file.out, row.names = > FALSE, col.names = FALSE) > Ok, almost there. I forgot to tell (because I didn't know) that the strings were separated by tabs (I just thought of splitting by _any_ space), and that

Re: [R] Hyper-elegant code to get a text file, transpose it, and write it

2008-06-05 Thread Alberto Monteiro
Uwe Ligges wrote: > >> Of course this is a trivial task: >> >> text.in <- readLines(file.in) >> matrix.in <- strsplit(text.in, "[ \t]+") > > You probably want > > write.table(t(read.table(file.in)), file = file.out, row.names = > FALSE, col.names = FALSE) > Unfortunately, it doesn't work. In f

Re: [R] Hyper-elegant code to get a text file, transpose it, and write it

2008-06-05 Thread Uwe Ligges
Alberto Monteiro wrote: Of course this is a trivial task: text.in <- readLines(file.in) matrix.in <- strsplit(text.in, "[ \t]+") You probably want write.table(t(read.table(file.in)), file = file.out, row.names = FALSE, col.names = FALSE) Uwe Ligges # matrix.out <- transpose matrix.in

[R] Hyper-elegant code to get a text file, transpose it, and write it

2008-06-05 Thread Alberto Monteiro
Of course this is a trivial task: text.in <- readLines(file.in) matrix.in <- strsplit(text.in, "[ \t]+") # matrix.out <- transpose matrix.in # loop over the lines of matrix.out creating text.out writeLines(text.out, file.out) What is the _most elegant_ way to write the transposition of matrix.in