Do you want just the values (i.e., a vector), or do you also want the
corresponding rows of the data frame?
What if there is a tie, or do you know in advance that within any
particular subset the values of B are unique?
What if the subset that meets the constraints has fewer than 3 unique
va
ust 2009 10:54
To: ottorino-luca.pant...@unifi.it
Cc: r help
Subject: Re: [R] Select top three values from data frame
I only have a few values in my example, but the real data set might have
20-100 rows with A="X". So how do I pick just the three highest ones?
-N
On 8/26/09 2:46 AM,
--
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Mohamed Lajnef
Sent: 26 August 2009 11:25
To: Noah Silverman
Cc: r help
Subject: Re: [R] Select top three values from data frame
Noah Silverman a écrit :
> I only have a few values in my example, but the r
Noah Silverman ha scritto:
I only have a few values in my example, but the real data set might
have 20-100 rows with A="X". So how do I pick just the three highest
ones?
-N
On 8/26/09 2:46 AM, Ottorino-Luca Pantani wrote:
df.mydata[df.mydata$A=="X" AND df.mydata$C < 2, ]
will do the job
Noah Silverman a écrit :
I only have a few values in my example, but the real data set might have
20-100 rows with A="X". So how do I pick just the three highest ones?
-N
Hi,
and now?
df.mydata$B[order(df.mydata[df.mydata$A=="X" AND df.mydata$C < 2,
]$B)][length(df.mydata$B)-3:length(d
rman
> Sent: 26 August 2009 10:54
> To: ottorino-luca.pant...@unifi.it
> Cc: r help
> Subject: Re: [R] Select top three values from data frame
>
>
> I only have a few values in my example, but the real data set might have
>
> 20-100 rows with A="X". So how do I pi
I only have a few values in my example, but the real data set might have
20-100 rows with A="X". So how do I pick just the three highest ones?
-N
On 8/26/09 2:46 AM, Ottorino-Luca Pantani wrote:
> df.mydata[df.mydata$A=="X" AND df.mydata$C < 2, ]
> will do the job ?
>
> 8rino
>
> Noah Silverm
df.mydata[df.mydata$A=="X" AND df.mydata$C < 2, ]
will do the job ?
8rino
Noah Silverman ha scritto:
Hi,
I'm trying to find an easy way to do this.
I want to select the top three values of a specific column in a subset
of rows in a data.frame. I'll demonstrate.
ABC
x21
x
Noah Silverman a écrit :
Hi,
I'm trying to find an easy way to do this.
I want to select the top three values of a specific column in a subset
of rows in a data.frame. I'll demonstrate.
Hi,
did you try this?
data[data$A=='x'& data$C<2,]$B # data = your data frame
ABC
x21
9 matches
Mail list logo