[R] first 3 minimums - works
Martin Wegmann
mailinglist2_wegmann at web.de
Sat Nov 1 14:36:56 CET 2003
On Saturday 01 November 2003 14:26, Jonathan Baron wrote:
> 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.
apply(df,2,sort)[1:3,] worked for my data set
thanks Berwin & Jonathan for the quick help! Martin
More information about the R-help
mailing list