Here is my data:
dat <- read.table(text = "id    val1    val2    vt
1   14  12  19
2   13  13  12
3   12  12  13
4   12  13  13
5   12  14  22
6   12  12  14
7   12  13  14
8   12  14  12
9   13  13  14
10  13  14  14
11  14  14  14
12  13  14  17
13  13  14  31
14  13  13  14
15  13  14  13
16  13  14  23
                
", header = TRUE)
I want to get the top 25 % and the bottom 45% according to vt.
Here is the output top25%
id  val1    val2    vt
13  13  14  31
16  13  14  23
5   12  14  22
1   14  12  19
and the top 45% is
id  val1    val2    vt
7   12  13  14
9   13  13  14
10  13  14  14
11  14  14  14
14  13  13  14
3   12  12  13
4   12  13  13
15  13  14  13
2   13  13  12
8   12  14  12
I have tried subset() with quantile, it seems it does not work for the bottom n%. Is it possible to do it with dplyr? I have checked the other links, they have not provided for the bottom n%. In addition, I do not want to get them by any group.
 
     
    