Re: [R] Change values in a dateframe-Speed TEST

2013-07-25 Thread arun
#   0.132   0.000   0.133 identical(res1,as.data.frame(dtNew)) #[1] TRUE A.K. ----- Original Message - From: Arnaud Michel To: Berend Hasselman Cc: R help Sent: Thursday, July 25, 2013 3:59 AM Subject: Re: [R] Change values in a dateframe-Speed TEST Le 25/07/2013 08:50, Berend Hasselm

Re: [R] Change values in a dateframe-Speed TEST

2013-07-25 Thread Arnaud Michel
Le 25/07/2013 08:50, Berend Hasselman a écrit : On 25-07-2013, at 08:35, Arnaud Michel wrote: But I just noticed that the two solutions are not comparable : the change concern only Nom and Prenom (solution Berend) and not also Sexe or Date.de.naissance orother variables (solution Arun) that c

Re: [R] Change values in a dateframe-Speed TEST

2013-07-24 Thread Berend Hasselman
On 25-07-2013, at 08:35, Arnaud Michel wrote: > But I just noticed that the two solutions are not comparable : > the change concern only Nom and Prenom (solution Berend) and not also Sexe or > Date.de.naissance orother variables (solution Arun) that can changed. But my > question was badly put

Re: [R] Change values in a dateframe-Speed TEST

2013-07-24 Thread Arnaud Michel
But I just noticed that the two solutions are not comparable : the change concern only Nom and Prenom (solution Berend) and not also Sexe or Date.de.naissance orother variables (solution Arun) that can changed. But my question was badly put. Michel Le 25/07/2013 08:06, Arnaud Michel a écrit :

Re: [R] Change values in a dateframe-Speed TEST

2013-07-24 Thread Arnaud Michel
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

Re: [R] Change values in a dateframe

2013-07-24 Thread arun
Hi Michel, You could try: df1New<-droplevels(TEST[with(TEST,ave(seq_along(Matricule),Matricule,FUN=min)),]) row.names(df1New)<-1:nrow(df1New) df2New<-droplevels(TEST[with(TEST,ave(seq_along(Matricule),Matricule,FUN=max)),]) row.names(df2New)<-1:nrow(df2New)  identical(df1New,df1) #[1] TRUE  ident

Re: [R] Change values in a dateframe

2013-07-24 Thread Arnaud Michel
Hi Arun, Merci à toi Bien amicalement Michel Le 24/07/2013 15:29, arun a écrit : Hi Michel, You could try: df1New<-droplevels(TEST[with(TEST,ave(seq_along(Matricule),Matricule,FUN=min)),]) row.names(df1New)<-1:nrow(df1New) df2New<-droplevels(TEST[with(TEST,ave(seq_along(Matricule),Matricule,FUN

Re: [R] Change values in a dateframe

2013-07-24 Thread Arnaud Michel
Thank you Berend It is exactly what I wanted. Michel Le 24/07/2013 09:48, Berend Hasselman a écrit : On 24-07-2013, at 08:39, Arnaud Michel wrote: Hello I have the following problem : The dataframe TEST has multiple lines for a same person because : there are differents values of Nom or diffe

Re: [R] Change values in a dateframe

2013-07-24 Thread Berend Hasselman
On 24-07-2013, at 08:39, Arnaud Michel wrote: > Hello > > I have the following problem : > The dataframe TEST has multiple lines for a same person because : > there are differents values of Nom or differents values of Prenom > but the values of Matricule or Sexe or Date.de.naissance are the sam