Hello all, I have a 2.0 GB dataset that I can't load into R, due to memory issues. The dataset itself is in a tab-delimited .txt file with 25 variables. I have a variable I'd like to add to the dataset. How do I do this? Best, Guillaume
How do I add a variable to a text file?
2 messages · Guillaume Filteau, Duncan Murdoch
On 19/03/2009 4:55 PM, Guillaume Filteau wrote:
Hello all, I have a 2.0 GB dataset that I can't load into R, due to memory issues. The dataset itself is in a tab-delimited .txt file with 25 variables. I have a variable I'd like to add to the dataset. How do I do this? Best,
Read a block, add the variable, write the block, and repeat? For
example, the reading part is done with
con <- file("somename.txt", "r")
block1 <- read.table(con, nrows=blocksize)
block2 <- read.table(con, nrows=blocksize, head=FALSE,
col.names=names(block1))
...
close(con)
The writing part is similar, but depends a lot on the details of what
you're doing.
Duncan Murdoch