Skip to content
Prev 278446 / 398513 Next

Is there way to add a new row to a data frame in a specific location

AFAIK all solutions to the "grow object size" problem in R involve creation of a new object to "change" an old one.  There is considerable sophistication under the hood that allows a minimum of intermediate objects to be created if you are careful, but actually changing the size of an object in place is not supported.

That doesn't mean that you have to "copy... to a temporary and then copy back", since you can reference chunks of an existing object without actually moving them in memory by using indexing. But (AFAIK) you cannot escape creating at least one new copy of the data that "becomes" the object if you use rbind to grow your object.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Sammy Zee <szee2007 at gmail.com> wrote: