I have a raster stack in r that contains 499 layers. Each layer has a specific name pattern.
[1] "Sacharovi_PA1_RUN1_GAM" "Sacharovi_PA1_RUN1_GLM"
[3] "Sacharovi_PA1_RUN1_RF" "Sacharovi_PA1_RUN1_CTA"
[5] "Sacharovi_PA1_RUN1_MAXENT.Phillips" "Sacharovi_PA1_RUN2_GAM"
[7] "Sacharovi_PA1_RUN2_GLM" "Sacharovi_PA1_RUN2_RF"
[9] "Sacharovi_PA1_RUN2_CTA"
What I want to do is save each model (GAM, RF, GLM, CTA, MAXENT) to a different stack. How can I select the models I want (all models containing the word "GAM"/"GLM"/"RF" etc.)?
Until now i have tried to do a subset of the raster stack as such:
result <- subset(my_stack, grep("GAM"))
but will not work. Could you please help me on that?