基于百分比的子集数据框 [英] subset data frame based on percentage

查看:18
本文介绍了基于百分比的子集数据框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含如下数据的数据框:

i have a data frame that contains a data like this :

V1 V2 V3
1  2  0.34
1  3  0.31
1  4  0.12
1  5  0.12

数据框更大,但这是一个例子.

the data frame is bigger but that's an example.

我想取这个数据框的一个子集,它具有 V3 的最低 20%.

i want to take a subset of this data frame that has the lowest 20% of V3.

如何做到这一点?

感谢帮助

推荐答案

subset() 函数很方便,因为(除其他好处外)它可以让您避免重复提及数据框:

The subset() function is handy because (among other benefits) it allows you to avoid having to repeatedly mention the name of the data-frame:

subset(dataFrame, V3 <= quantile(V3, 0.2))

这篇关于基于百分比的子集数据框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆