Suppose I have a matrix in R as follows:
ID Value 1 10 2 5 2 8 3 15 4 7 4 9 ...
What I need is a random sample where every element is repre
You can do that with dplyr like so:
library(dplyr) df %>% group_by(ID) %>% sample_n(1)