ll=TRUE)
Name length type
1 a 1.5 x
2 b 3.5
A.K.
- Original Message -
From: Filoche
To: r-help@r-project.org
Cc:
Sent: Tuesday, July 3, 2012 12:04 PM
Subject: [R] Data manipulation with aggregate
Hi everyone.
I have these data :
myData = data.frame(Name =
try this:
> myData = data.frame(Name = c('a', 'a', 'b', 'b'), length = c(1,2,3,4), type
+ = c('x','x','y','z'))
>
> result <- do.call(rbind, lapply(split(myData, myData$Name), function(.name){
+ data.frame(Name = .name$Name[1L]
+ , length = mean(.name$length)
+ , type = if (all(.name$type[1L] == .
Hi everyone.
I have these data :
myData = data.frame(Name = c('a', 'a', 'b', 'b'), length = c(1,2,3,4), type
= c('x','x','y','z'))
which gives me:
Name length type
1a 1x
2a 2x
3b 3y
4b 4 z
I would group (mean) this DF using 'Name' as grouping
3 matches
Mail list logo