Skip to content
Prev 45170 / 63424 Next

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.
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