[R] insert/copy skipped lines to output
Muhammad Rahiz
muhammad.rahiz at ouce.ox.ac.uk
Sat Mar 27 12:42:47 CET 2010
Hello all,
I'd like some advise on this. When I read my files, I pass the argument,
skip=6, to skip 6 lines of header information. After performing the
desired calculations, I have the output. Now I want to copy the 6 lines
of skipped information to the output.
What I've been doing so far is to use a shell script (i.e. the cat
function) to copy the header information to the output file. This means
I need 2 additional files, namely a file containing the header
information only, and the shell script to run the the function.
Is there a direct way to perform this in R?
The following forms the main component of my R script;
x <- as.matrix(read.table("file.txt",skip=6))
y <- x*2
write.table(y,"output.txt",row.names=FALSE,col.names=FALSE)
Thanks
Muhammad
More information about the R-help
mailing list