Skip to content
Prev 15781 / 398500 Next

combine

On 19.12.2001 9:26 Uhr, Nando Foppa wrote:

            
Yes, use cbind() or data.frame(). You can e.g. do this (should work for most
well-behaved text files):

col1 <- scan("filename1")
col2 <- scan("filename2")
mydata <- data.frame(col1, col2)  # or the same with cbind(...)
write.table(mydata, file="filename3")

For more information on reading files into/from R, read the "R Data
Import/Export" manual which gets installed by default. See also
help(write.table), help(read.table), help(scan) for details on the functions
(such as specifying header rows, separators, N/A coding...).
Depends on what you want to do with the data. For reading into R, both ways
work (for multi-column files, you'll want to use read.table() instead of
scan()).

Cheers

Kaspar