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

Ian Strang hamamelis at ntlworld.com
Fri Nov 25 20:10:56 CET 2011


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),]



More information about the R-help mailing list