[R] first 3 minimums
Jonathan Baron
baron at psych.upenn.edu
Sat Nov 1 14:26:01 CET 2003
On 11/01/03 14:05, Martin Wegmann wrote:
>Hello,
>
>I have a df with plots (60) and their distances to bores (20) and would like
>to compute the three minimum distances to bores of each plot.
>
>with
>>apply(df, 2, min)
>I get the overall min, but is there a way to get additionally to the first
>min, the second and third minimum distance?
Something like:
apply(df,2,sort)[1:3,]
or
apply(df,2,sort)[,1:3]
or
apply(df,1,sort)[,1:3]
or
apply(df,1,sort)[1:3,]
I can't think through how your data are laid out, but I'm pretty
sure one of these will work.
Jon
--
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
R page: http://finzi.psych.upenn.edu/
More information about the R-help
mailing list