> Is there a built-in and simple way to insert new columns in a dataframe?

You do this by collecting the columns in the new order you desire, and
making a new frame.

oldframe           <- data.frame(matrix(0:14,ncol=3))
newcol              <- data.frame(20:24)
names(newcol) <- "newcol"
newframe         <- data.frame(c(oldframe[1],newcol, oldframe[2:3]))

______________________________________________
R-help@stat.math.ethz.ch 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