Skip to content
Prev 327395 / 398502 Next

Change values in a dateframe-Speed TEST

On 25-07-2013, at 08:35, Arnaud Michel <michel.arnaud at cirad.fr> wrote:

            
Indeed:-)

But that can be remedied with (small correction w.r.t. initial solution: drop=TRUE removed; not relevant here)

r1 <- droplevels(do.call(rbind,lapply(split(TEST,TEST$Matricule),
                    FUN=function(x) {x[,1:ncol(x)] <- x[1,1:ncol(x)];x})))

and

r2 <- droplevels(do.call(rbind,lapply(split(TEST,TEST$Matricule),
                    FUN=function(x) {x[,1:ncol(x)] <- x[nrow(x),1:ncol(x)];x})))

Less elegant than alternative with ave

Berend