samedi 18 février 2023

How to take a random sample from mutliple groups with unequal sample sizes (in R)

I have a dataset that I want to randomly sample up to 6 rows for each animal ID per day. Not every animal ID was sampled each day, and some animals were sampled less than 6 times per day. For example - if an animal was only sampled 2 times in a given day, then I want to retain both those samples. I want to retain all the info in the sampled row.

in the image:

  • New_ID is the animal Id
  • New_Date_Hour is the hour of the day (this is the variable that I want to randomly sample 6 times per day)

There are 13 different animal IDs

[Image of Example data]

I have tried a few different approaches but without success.




Aucun commentaire:

Enregistrer un commentaire