Re: [R] Is there way to add a new row to a data frame in a specific location

2011-11-25 Thread David Winsemius
On Nov 25, 2011, at 2:10 PM, Ian Strang wrote: This look really interesting but I don't understand what is happening. Please can someone explain the last line and what the bit in [] is doing. Ian You just stick the new line on the bottom and return the rows in the order specified in the

Re: [R] Is there way to add a new row to a data frame in a specific location

2011-11-25 Thread Ian Strang
This look really interesting but I don't understand what is happening. Please can someone explain the last line and what the bit in [] is doing. Ian df = data.frame( A=c('a','b','c'), B=c(1,2,3), C=c(10,20,30), stringsAsFactors=FALSE) newrow = c('X', 100, 200) rbind(df,newrow)[c(1,4,2,3),] ___

Re: [R] Is there way to add a new row to a data frame in a specific location

2011-11-24 Thread Prof Brian Ripley
On Thu, 24 Nov 2011, Jeff Newmiller wrote: 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, bu

Re: [R] Is there way to add a new row to a data frame in a specific location

2011-11-24 Thread Jeff Newmiller
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

Re: [R] Is there way to add a new row to a data frame in a specific location

2011-11-24 Thread andrija djurovic
Hi. May be this: df = data.frame( A=c('a','b','c'), B=c(1,2,3), C=c(10,20,30), stringsAsFactors=FALSE) newrow = c('X', 100, 200) rbind(df,newrow)[c(1,4,2,3),] Andrija On Thu, Nov 24, 2011 at. 6:05 PM, Sammy Zee wrote: > Is there easy way (without copying the existing rows to a temporary > l

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

2011-11-24 Thread Sammy Zee
Is there easy way (without copying the existing rows to a temporary location and copying back) to add a new row to a specific index location in an existing data frame? Example df = data.frame( A= c('a','b','c'), B=c(1,2,3), C=(10,20,30)) newrow = c('X', 100, 200) I want to add the newrow as the