
Benjamin B. answered 06/21/19
Ecologist with 4 years of R and research experience
You will need to use a package called Tidyverse. The main functions you need are group_by and summarize. I don't know the names of your data sets, so i will use the name "data" to refer to your datatable, "category" to refer to the column heading of your categories, and "count" to refer to the counts that you have.
The following code also uses something called "pipes". Pipes allow for you to run multiple connected functions without having to write the name of the data-table in each line.
If you have used the name conventions I state below, your code should look something like this:
data2<-data%>%
group_by(category)%>%
summarize(sum=sum(count))