My mistake.

cars2 should be initalized to have all the extra rows.

cars2 <- data.frame(matrix(rep(NA, prod(dim(cars)) + ncol(cars)),  
nrow(cars)+1))
cars2[2:nrow(cars2),] <- cars

In this way, insertion at any row is possible.

Nikhil

On May 17, 2010, at 2:46 PM, Peter Ehlers wrote:

>>>> data(cars)
>>>> cars2 <- cars
>>>> cars2[2:nrow(cars)+1,] <- cars2[1:nrow(cars),]
>>>> cars2[1,] <- NA


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to