Re: [R] aggregate dataframe by multiple factors

2016-11-20 Thread Karim Mezhoud
;>> same result can be achieved by > > >>> > > >>> dat.ag<-aggregate(dat[ , c("DCE","DP")], by= list(dat$first.Name, > dat$Name, dat$Department) , "I") > > >>> > > >>> Sorting according to the first row seems

Re: [R] aggregate dataframe by multiple factors

2016-11-20 Thread David Winsemius
; >>> Sorting according to the first row seems to be quite tricky. You could > >>> probably get closer by using some combination of split and order and > >>> arranging back chunks of data > >>> > >>> ooo1<-order(s

Re: [R] aggregate dataframe by multiple factors

2016-11-20 Thread Karim Mezhoud
tricky. You could > probably get closer by using some combination of split and order and > arranging back chunks of data > >>> > >>> ooo1<-order(split(dat$DCE,interaction(dat$first.Name, dat$Name, > dat$Department, drop=T))[[1]]) > >>> data.frame

Re: [R] aggregate dataframe by multiple factors

2016-11-20 Thread David Winsemius
dat$Name, >>> dat$Department, drop=T))[[1]]) >>> data.frame(sapply(split(dat$DCE,interaction(dat$first.Name, dat$Name, >>> dat$Department, drop=T)), rbind))[ooo1,] >>> Ancient.Nation.QLH Amish.Wives.TAS Auction.Videos.YME >>> 2

Re: [R] aggregate dataframe by multiple factors

2016-11-20 Thread David Winsemius
NA > > 4 0.28 NA NA > > 1 0.540.59 0.57 > > 3 0.540.59 0.57 > > > > however I wonder why the order according to the first row is n

Re: [R] aggregate dataframe by multiple factors

2016-11-20 Thread Karim Mezhoud
st row is necessary > if all NAs are on correct positions? > > > > Cheers > > Petr > > > > > > > -Original Message- > > > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David > > > Winsemius > > > Sent: Friday, No

Re: [R] aggregate dataframe by multiple factors

2016-11-20 Thread David Winsemius
0.59 0.57 > 3 0.540.59 0.57 > > however I wonder why the order according to the first row is necessary if all > NAs are on correct positions? > > Cheers > Petr > > > > -Original Message- > >

Re: [R] aggregate dataframe by multiple factors

2016-11-20 Thread Karim Mezhoud
0.540.59 0.57 > > however I wonder why the order according to the first row is necessary if > all NAs are on correct positions? > > Cheers > Petr > > > > -Original Message- > > From: R-help [mailto:r-help-boun...@r-project.org]

Re: [R] aggregate dataframe by multiple factors

2016-11-18 Thread PIKAL Petr
necessary if all NAs are on correct positions? Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David > Winsemius > Sent: Friday, November 18, 2016 9:30 AM > To: Karim Mezhoud > Cc: r-help@r-project.org > Subject: R

Re: [R] aggregate dataframe by multiple factors

2016-11-18 Thread David Winsemius
> On Nov 17, 2016, at 11:27 PM, Karim Mezhoud wrote: > > Dear all, > > the dat has missing values NA, > >first.Name Name Department DCE DP date > 5 Auction VideosYME 0.57 0.56 2013-09-30 > 18 Amish WivesTAS 0.59 0.56 2013-09-30 > 34 Ancient Natio

[R] aggregate dataframe by multiple factors

2016-11-17 Thread Karim Mezhoud
Dear all, the dat has missing values NA, first.Name Name Department DCE DP date 5 Auction VideosYME 0.57 0.56 2013-09-30 18 Amish WivesTAS 0.59 0.56 2013-09-30 34 Ancient NationQLH 0.54 0.58 2013-09-30 53 Auction VideosYME NA