I have a table set up like this
Site | Replicate | Species | Value A |
---|---|---|---|
A | A | A | 1 |
A | A | B | 2 |
A | B | A | 3 |
B | A | A | 3 |
B | A | B | 4 |
B | B | B | 6 |
B | B | C | 2 |
C | A | A | 5 |
C | A | B | 6 |
And I want to calculate the average of value A according to every site and species combination.
I have tried using the group_by function from the dplyr package with this code:
mean_valueA=invertebrates%>%
group_by(site, species) %>%
summarize(mean_val=mean(value A))
but it only seems to group by site without taking into consideration the species. Is there anyway to solve this issue?
Thanks for your help!
New contributor
capthom_obvious is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.