Skip to content

aggregate by factor

5 messages · David Winsemius, david hilton shanabrook, Dennis Murphy

#
On Jan 30, 2010, at 4:09 PM, david hilton shanabrook wrote:

            
I don't think grouping on a factor is the source of your error. You  
have NA's in your data and median will choke on those unless you  
specify na.rm=TRUE.
#
On Jan 30, 2010, at 4:46 PM, david hilton shanabrook wrote:

            
I missed that.
Apparently you cannot include the grouping variable in the first  
argument to aggregate:

motifTable3 <- aggregate(motifTable2[ , -1],  
by=list(motifTable2$events), FUN=median, na.rm=TRUE)

 > motifTable3
   Group.1       score freq
1   aehjm  0.08333333    1
2   aeijm -0.25000000    2
3   afgjm -0.25000000    1
4   afhjm -0.25000000    1
5   begjm -0.25000000    1
David Winsemius, MD
Heritage Laboratories
West Hartford, CT