You can do it in a "tough" way. For transparency, you can use names.
with( dat, data.frame(iter = rep(iter, 3), model = rep(1:3, each = nrow(dat)), err = c(err_1, err_2, err_3), rel_err = c(rel_err_1, rel_err_2, rel_err_3), test_type = rep(test_type, 3)) )
Or, for brevity, indexes.
data.frame(iter = dat[,1], model = rep(1:3, each = nrow(dat)), err = dat[,c(2, 4, 6)], rel_err = dat[,c(3, 5, 7)], test_type = dat[,8]) )
If you had many columns, the hard way might include grepping column names.
This "hard" method was about as brief as reshape and required less thought about how to use the commands. Sometimes I just miss thoughts about reshape .
source share