Skip to content
Prev 327393 / 398503 Next

Change values in a dateframe-Speed TEST

Hi

For a dataframe with name PaysContrat1 and with
nrow(PaysContrat1)
[1] 52366

the test of system.time is :

system.time(droplevels(do.call(rbind,lapply(split(PaysContrat1,PaysContrat1$Matricule),
FUN=function(x) {x[,c("Nom","Pr?nom")] <- 
x[nrow(x),c("Nom","Pr?nom"),drop=TRUE];x}))))
    user  system elapsed
   14.03    0.00   14.04

system.time(droplevels(PaysContrat1[with(PaysContrat1,ave(seq_along(Matricule),Matricule,FUN=min)) 
,]  ))
    user  system elapsed
     0.2     0.0     0.2

Michel

Le 24/07/2013 15:29, arun a ?crit :