How do you do that Henrik? Write.table doesn't have that option. Usage: write.table(x, file = "", append = FALSE, quote = TRUE, sep = " ", eol = "\n", na = "NA", dec = ".", row.names = TRUE, col.names = TRUE, qmethod = c("escape", "double"))
- Gundala Viswanath Jakarta - Indonesia On Sun, Jan 18, 2009 at 12:09 AM, Henrik Bengtsson <h...@stat.berkeley.edu> wrote: > Do it in chunks of rows. /H > > On Sat, Jan 17, 2009 at 6:55 AM, Gundala Viswanath <gunda...@gmail.com> wrote: >> Hi Hadley, >> >> I had to do it by line. Because, in practice, I will >> manipulate the figures and string before printing it. >> >> And I can't bind these results into one new object, >> because there are literally millions of this lines, and >> R object can't handle that in my 4GB Ram memory. >> >> I tried your suggestion already, I have memory problem >> >>> x <- cbind(dat$V1, as.character(dat$V2)) >> Error: cannot allocate vector of size 4.2 Gb >> Execution halted >> >> - Gundala Viswanath >> Jakarta - Indonesia >> >> >> >> On Sat, Jan 17, 2009 at 11:39 PM, hadley wickham <h.wick...@gmail.com> wrote: >>> On Sat, Jan 17, 2009 at 7:59 AM, gundalav <gunda...@gmail.com> wrote: >>>> Dear Jim and all, >>>> >>>> Allow me to ask your expert opinion. >>>> >>>> >>>> Using the data (16Mb) downloadable from here: >>>> >>>> http://drop.io/gundalav/asset/test-data-zip >>>> >>>> >>>> It took this long under 1994.070Mhz Cpu Linux, using >>>> "write.table" >>>> >>>>> proc.time() - ptm1 >>>> user system elapsed >>>> 16581.833 5787.228 21386.064 >>>> >>>> >>>> >>>> __MYCODE__ >>>> >>>> args <- commandArgs(trailingOnly=FALSE) >>>> fname <- args[3] >>>> dat <- read.delim(fname, header=FALSE); >>>> >>>> output <- file('output_writetable.txt', 'w') >>>> >>>> >>>> ptm1 <- proc.time() >>>> for (i in 1:nrow(dat)) { >>>> >>>> #cat(dat$V1[i]," ", as.character(dat$V2[i]),"\n", sep="") >>>> write.table(cbind(dat$V1[i], as.character(dat$V2[i])), >>>> file=output, sep="\t", quote=FALSE, col.names=FALSE, row.names=FALSE) >>>> } >>>> >>>> close(output) >>>> proc.time() - ptm1 >>>> __END__ >>>> >>>> Perhaps I misunderstood you. But seems that this is >>>> truly slow. Is there a way I can speed it up? >>> >>> Don't do it line by line! >>> >>> write.table(dat[, c("V1", "V2")], file='output_writetable.txt', >>> sep="\t", quote=FALSE, col.names=FALSE, row.names=FALSE) >>> >>> Hadley >>> >>> -- >>> http://had.co.nz/ >>> >> >> ______________________________________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.