I have a two-column data.frame that looks a little like this:
df <- data.frame(Name = rep(paste(letters[1:12],1:12,sep = ""),1),Group = 1:3)
What I would like to do is to randomly select, for example, 2 random values (without replacement) from 'Name' and store them in a character vector. Then select two other values, and store them in another vector, and so on. The requirement is that the values sampled from 'Name' must have the same value in 'Group'.
Is there a fast way of doing this? I could manually create vectors based in a sample of n=2, then update the contents of the original df, and sample again. But I would love to see someone suggesting a more elegant version. Maybe if I store the sampled values in a list?
Thanks in advance.