Message-ID: <1361356957.702.YahooMailClassic@web125105.mail.ne1.yahoo.com>
Date: 2013-02-20T10:42:37Z
From: Suharto Anggono Suharto Anggono
Subject: Simultaneously adding rows and columns by '[<-.data.frame' may fail
I saw the following in R help page "Extract.data.frame".
The replacement methods can be used to add whole column(s) by
specifying non-existent column(s), in which case the column(s) are
added at the right-hand edge of the data frame and numerical
indices must be contiguous to existing indices. On the other
hand, rows can be added at any row after the current last row, and
the columns will be in-filled with missing values.
So, I tried something like this.
> x <- data.frame(a=1, s=1)
> y <- data.frame(a=1, r=8, e=9)
> z <- x
> z[2, c("a","r","e")] <- y
Error in `*tmp*`[[j]] : recursive indexing failed at level 2
Using debug("[<-.data.frame") revealed that execution stopped at this line.
length(x[[j]]) <- nrows