[R] rbind-ing with empty data frame produces error
jon.clayden at gmail.com
Thu Jan 25 16:22:14 CET 2007
I'm having some trouble with rbind - this may be a bug or it may be my
misunderstanding. If I do
fileName <- paste(tempdir(),"test.txt",sep="/")
x <- read.table(fileName, col.names=c("one","two","three"))
I get a data frame with no rows, as documented. If I then try to rbind
this with another data frame with the same column names, I get an
y <- data.frame(one=1,two=2,three=3)
"Error in `*tmp*`[[jj]] : subscript out of bounds"
On the other hand, doing "rbind(as.matrix(x),as.matrix(y))" works as
expected. If this is, in fact, intended behaviour, could anyone
suggest another way of achieving what I want, please? I'm trying to
append to a data frame stored in a text file every so often, and of
course I need to create it, as above, the first time around...
My system is R-2.4.1/i686-pc-linux-gnu. Thanks in advance for your advice.
More information about the R-help