I have a data frame such as
df <- data.frame(matrix(rnorm(40), nrow=20))
df$color <- rep(c("blue", "red", "yellow", "pink"), each=5)
df$score <- rep(c(1,2,3,5), each = 5)
I want to sample the rows based on two columns color and score into two data frames such that I get an almost equal number of rows from each group in each data frame. For example, I have 5 rows with the color blue and score 1. I want 2 in one data frame and 3 in another data frame. If I have sis rows in a group 3 should go to one data frame and 3 to another.