# I want to be able to collapse and sum values dependent on the gene name

I have a table that looks like this:

I want add together all the values for each gene for each column. For example, for LINC01128, it should read: ConN1 ConN2 ConN3 StN1 StN2 StN3 LINC01128 : 22 14 37 34 54 67

My table is very long and this would need to be done for all the genes.

• apply(table,1,sum) – user2974951 Oct 3 '18 at 10:41

You can use dplyr, where df is your data.frame:
df %>% group_by(gene) %>% summarise_if(is.numeric, sum)

This will sum each column separately (assuming it is numeric), grouped by each gene. Any column that is not included in the group_by or is not numeric will be dropped at this stage.
data = aggregate(data,