Subset of data depending on percentage

I have a data frame that contains such data:

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

the data frame size is larger, but an example.

I want to take a subset of this data frame, which has the lowest 20% of V3.

How can I do that?

thanks for the help

+6
source share
2 answers

The subset() function is convenient because (among other advantages), it avoids the repeated mention of a data frame name:

 subset(dataFrame, V3 <= quantile(V3, 0.2)) 
+19
source

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

+4
source

Source: https://habr.com/ru/post/889875/


All Articles