Re: [R] Average calculations

2013-01-23 Thread arun
(x1$Values,list(x1$Names),function(x) mean(head(x,2))) #CK113234 CK113298 CK114042 CK116292 CK116296 #222.9852 190.1725 234.2081 232.7987 217.1501 A.K. - Original Message - From: Nico Met To: R help Cc: Sent: Wednesday, January 23, 2013 8:03 AM Subject: [R] Average calculations D

Re: [R] Average calculations

2013-01-23 Thread Jose Iparraguirre
216.5061 190.1725 222.8710 220.4324 204.5741 Hope it helps. José José Iparraguirre Chief Economist Age UK -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Nico Met Sent: 23 January 2013 13:04 To: R help Subject: [R] Average calcu

[R] Average calculations

2013-01-23 Thread Nico Met
Dear all, I have a matrix with two columns: "Names" and "Values" In names: there are 4 groups they are, CK113234, CK116296, CK116292 and CK114042 I want to *sort values* (decreasing order) based on each group and take average of the *top two numbers* in each of the groups. > dput(x) structure(