[R] data formatting: from rows to columns

Duncan Mackay mackay at northnet.com.au
Wed Aug 29 01:44:30 CEST 2007


At 09:11 29/08/07 Jim Holtman wrote

Here is a way using sprintf:

x <- read.table(textConnection("         V2  V3
27  2032567  19
28  2035482  19
126 2472826  19
132 2473320  19
136 2035480 135
145 2062458 135
148 2074927 135
151 2102395 142
156 2027252 142
158 2473082 142"))

# output the data
cat(sprintf("%d\n%d\n\n", x$V2, x$V3), sep='', file='tempxx.txt')

How about

write.table(x,"clipboard",sep="\n",eol="\n\n",col.names = FALSE, row.names 
= FALSE)
2032567
19

2035482
19

2472826
19

2473320
19

2035480
135

2062458
135

2074927
135

2102395
142

2027252
142

2473082
142

Regards

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: dmackay9 at pobox.une.edu.au
Ph 02 67729794



More information about the R-help mailing list