I have a data frame that I want to subset by randomly selecting 25 values of ID based on spp=cat and 25 values of ID based on spp=dog.
Here is my example data:
ID spp category prop
1 cat small_mam 0.99
2 cat small_mam 0.8
2 cat birds 0.15
3 dog large_mam 1
4 dog med_mam 0.4
4 dog emu 0.6
10 dog med_mam 0.8
10 dog birds 0.2
12 dog reptiles 1
13 dog large_mam 1
14 dog large_mam 1
15 dog large_mam 1
27 cat birds 0.2
28 cat small_mam 1
29 cat small_mam 0.75
29 cat birds 0.25
30 cat small_mam 0.7
30 cat birds 0.2
ID values for spp are unique meaning that cat and dog never have the same ID value. ID ranges from 1 to 696 but is not necessarily unique, this is because ID can be composed of up to 7 categories so randomly sub-setting 25 rows for each species does not work.
The context behind this question is that I will be drawing 1000 random samples of 25 cat and 25 dog scats (UID = the scat ID number) for a bootstrap calculation of dietary overlap using the piankabio function in package(pgirmess).
Thanks in advance for any help.
I am using R version 3.1.3
Aucun commentaire:
Enregistrer un commentaire