Find the most frequent value in a column and take a subset of that
I have the following dataset.
Num Day Value
1111 Thursday 2
2222 Thursday 2
3333 Thursday 3
1111 Monday 3
1111 Tuesday 3
1111 Wednesday 3
1111 Friday 4
1111 Saturday 5
1111 Sunday 6
2222 Thursday 6
We can get the highest value in a column value
using the following command:tail(names(sort(table(data$value))), 1)
I need to dynamically get a subset of the data containing only that highest value.
Thus, I need the following output:
Num Day Value
3333 Thursday 3
1111 Monday 3
1111 Tuesday 3
1111 Wednesday 3
+3
source to share
1 answer