I am trying to summarize data across multiple columns automatically if at all possible rather than writing code for each column independently. I would like to summarize this:
Patch Size Achmil Aciarv Aegpod Agrcap
A 10 0 1 1 0
B 2 1 0 0 0
C 2 1 0 0 0
D 2 1 0 0 0
into this
Species Presence MaxSize MeanSize Count
Achmil 0 10 10 1
Achmil 1 2 2 3
Aciarv 0 2 2 3
Aciarv 1 10 10 1
I know that I can individually run group_by and summarize for each column
achmil<-group_by(LimitArea, Achmil) %>%
summarise(SumA=mean(Size))
but is there no way to automatically run this for each column for each presence and absence using some sort of loop? Any help is appreciated.