Dear Johannes,
If 'x' is your data set, here is one way using apply:
res <- apply(x[,-1], 1, function(x){
xo <- sort(x, decreasing = TRUE)
mean(xo[1:3])
}
)
names(res) <- x[,1]
res
# ABC
# 5.67 5.00 5.3
On Wed, Jul 15, 2009 at 3:37 AM, Hatsch wrote:
>
> Hi all,
>
> I have a problem with computing a new variable as an aggregated score of
> other variables.
>
> Say, I have 10 variables for 1,000 observations (people). Every variable may
> have values between 0 and 8. What I would like to do is compu
Hi all,
I have a problem with computing a new variable as an aggregated score of
other variables.
Say, I have 10 variables for 1,000 observations (people). Every variable may
have values between 0 and 8. What I would like to do is computing the mean
of the individual top 3 values for every perso
3 matches
Mail list logo