Hey, as the title states I need to collapse two rows into a singular row, I found some code on
stack overflow and tweaked it.
As a side note I need to do basically the exact same thing as this but with 5 categories as well. I tried to use a suggested method for 2+ rows but I understood it less than this one.
aggregate(data_chemistry_code_sum, list(Group=replace(rownames(chem), rownames(chemistry) %in% c("chem","chemistry"), "chemistry")), sum)
This code gets the error
Error in rownames(chem) : object 'chem' not found
An image of my data is posted below
Any help would be appreciated!