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

Alberto Monteiro albmont at centroin.com.br
Thu Jun 5 13:32:51 CEST 2008


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 (that is _not_ a matrix) and the pasting of the
lines of matrix.out?

Alberto Monteiro

PS: this is not a homework, this is evangelism to a Visual Basic
programmer :-)



More information about the R-help mailing list