I have a dataset like this:
> head(test,20)
Temp Precip species
3 9.4007956 59.27015 oak
4 -0.4519635 47.40692 scots_pine
5 11.6495457 64.51529 beech
6 5.2807114 101.44833 picea_abies
9 5.3833591 53.95441 scots_pine
10 7.3652109 88.80829 picea_abies
11 8.9340262 69.37932 beech
13 8.8422581 94.94867 picea_abies
14 4.2412035 55.40555 scots_pine
27 4.2412035 55.40555 picea_abies
28 10.4218126 63.84373 beech
29 8.5513810 89.79829 beech
32 10.8957457 58.20228 oak
35 7.6330249 55.74190 beech
38 4.1350583 105.62783 picea_abies
39 4.7160738 58.02741 picea_abies
40 10.1936149 66.41384 oak
41 5.9420923 81.82859 beech
45 8.9224902 50.62589 scots_pine
46 9.0305198 49.18080 scots_pine
I want to create different bins for each species to describe the different climate conditions that the species are distributed in. An example output would be that Picea abies may overall live in 2 different bins of temperature-precipitation that include most of the species plots, one in 4-8ºC and 60mm rainfall and the other characterised by 4-8ºC and 100mm rainfall. I want R to tell me which bins are the best to explain and group the climate distribution of these species.
How can I do this in R automatically? I have been told moving windows are useful but I have no idea how I can automate this in R. Thanks