For randomly sampling a row/cell where a condition is in another cell, you can use sample as follows:
# Dummy data: data = value of interest, g = gender (0,1)
data1 <- data.frame("data" = rnorm(10, 0, 1), "g" = sample(c(0,1), replace = T, size = 10))
Then you can use the dplyr package in the following way:.
pull(data1 %>% group_by(g) %>% sample_n(1), data)