开发者

subset data frame based on percentage

开发者 https://www.devze.com 2023-03-10 13:26 出处:网络
i have a data frame that contains a data like this : V1 V2 V3 120.34 130.31 140.12 150.12 the data frame is bigger but that\'s an example.

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.

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

how this can be done 开发者_JS百科?

thanks for help


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))


ss <- subset(dataFrame, subset=(dataFrame$V3 <= quantile(dataFrame$V3, 0.20)))
0

精彩评论

暂无评论...
验证码 换一张
取 消