Reputation: 10626
I have a data like this:
df:
Group Point
A 6000
B 5000
C 1000
D 100
F 70
Before I graph this df, I only like to remove values over than 95th percentile in my data frame. Any body tell me how to do that?
Upvotes: 23
Views: 45957
Reputation: 606
Or using 'dplyr' library:
> quantile(d$Point, 0.95)
95%
5800
> df %>% filter(Point < quantile(df$Point, 0.95))
Group Point
1 B 5000
2 C 1000
3 D 100
4 F 70
Upvotes: 13
Reputation: 49810
Use the quantile
function
> quantile(d$Point, 0.95)
95%
5800
> d[d$Point < quantile(d$Point, 0.95), ]
Group Point
2 B 5000
3 C 1000
4 D 100
5 F 70
Upvotes: 51