Re: [R] insert/copy skipped lines to output

2010-03-28 Thread David Winsemius
On Mar 28, 2010, at 2:41 PM, Muhammad Rahiz wrote: something like this... x1 <- as.matrix(read.table("input.txt"))[1:6,] # reads only header x2 < -array(1:6,dim=c(2,3)) write(x,"output.txt") write() will process the matrix elements in their natural "vector" order. write .table(x3,"outp

Re: [R] insert/copy skipped lines to output

2010-03-28 Thread Muhammad Rahiz
something like this... x1 <- as.matrix(read.table("input.txt"))[1:6,] # reads only header x2 < -array(1:6,dim=c(2,3)) write(x,"output.txt") write.table(x3,"output.txt",row.names=FALSE,col.names=FALSE,append=TRUE) But the results print; ncols nrows xllcorner yllcorner cellsize NODATA_value 1

Re: [R] insert/copy skipped lines to output

2010-03-28 Thread David Winsemius
On Mar 28, 2010, at 1:11 PM, Muhammad Rahiz wrote: Yes, it works. Just wondering if the technique can be optimized... IN WHAT WAY -- David. David Winsemius wrote: On Mar 28, 2010, at 12:51 PM, Muhammad Rahiz wrote: Dear Jannis, Thanks for the tip. It works but I'd like to improve

Re: [R] insert/copy skipped lines to output

2010-03-28 Thread Muhammad Rahiz
Yes, it works. Just wondering if the technique can be optimized... David Winsemius wrote: On Mar 28, 2010, at 12:51 PM, Muhammad Rahiz wrote: Dear Jannis, Thanks for the tip. It works but I'd like to improve on the way I did it. x <- array(1:50,dim=c(10,10)) # data h1 <- c("ncols

Re: [R] insert/copy skipped lines to output

2010-03-28 Thread David Winsemius
On Mar 28, 2010, at 12:51 PM, Muhammad Rahiz wrote: Dear Jannis, Thanks for the tip. It works but I'd like to improve on the way I did it. x <- array(1:50,dim=c(10,10)) # data h1 <- c("ncols180") # header, line 1 h2 <- c("nrows 290") # header, line 2 h3 <- c(

Re: [R] insert/copy skipped lines to output

2010-03-28 Thread Muhammad Rahiz
Dear Jannis, Thanks for the tip. It works but I'd like to improve on the way I did it. x <- array(1:50,dim=c(10,10)) # data h1 <- c("ncols180") # header, line 1 h2 <- c("nrows 290") # header, line 2 h3 <- c("xllcorner -20") # header, line 3 h4 <- c("y

Re: [R] insert/copy skipped lines to output

2010-03-28 Thread Jannis
Hallo, have a look at the documentation of the different output functions (write(),cat(),write.table()). Most of them have an argument like "append". If you set this to TRUE, your command adds the lines you are writing into the file to the lines already existent in that file. So if you run this w

[R] insert/copy skipped lines to output

2010-03-27 Thread Muhammad Rahiz
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