I have a stimuli set (just an example, not a real data set):
df<- data.frame(A = c("dog", "cat", "bear", "zebra),
B = c("mosquito", "cockroach", "fly", "worm")
and I would like to randomly sample one from this data set. This should be an easy one, but I cannot seem to find a way.
sample(df, size = 1, replace = T)
returns one whole column, not just one (i.e. just "dog").
Does anyone happen to know how I can solve this problem?
Thank you.
Aucun commentaire:
Enregistrer un commentaire