Re: [R] Find the three best values in every row

2010-05-07 Thread Alfred-Schulze
], n=3)) > >#Get them with names >get.n<- function(x, names, n) { > rmin<- > rv<-x[w<-which(rank(x)> length(x)-n)] > names(rv)<-names[w] > return(as.data.frame(rv)) >} > >apply(d,1,get.n, n=3, names=names(d)) > &g

[R] Find the three best values in every row

2010-05-07 Thread Alfred Schulze
Hello, i have a dataframe with the GDP for different Country (in the columns) and Years (in the rows). Now i want for every year the best three values, if possible with name of the countries (columnnames). For the best it's no problem but for the other two values. Thanks,