I have found a way to do the procedure I want to do, but I'm stuck on how to repeat that 100 or 1000 times.
Basically, I want to sample a random observation (indvd_ID) from each group (group_ID) in the dataset (flowers). Then I want to test whether the number of hits (No_hits) is higher on average for individuals of group A or group B, using a Mann-Whitney U test.
The code I wrote to do this is:
library(dplyr)
random_indvdIDs <- flowers %>% group_by(group_ID) %>% sample_n(1)
wilcox.test(random_indvdIDs$No_hits ~ random_indvdIDs$A_or_B)
I think I need to write a for loop, and then get it to print the p-value of the wilcox.test each time, but I'm struggling to do so!
I'm a bit of a noob so thanks very much to anyone who has an idea how to help. :)