I have a data df as shown below.
- df$gene_namecontains names of genes, each row is a unique identifier.
- df$gene_typeindicates the gene type, there are several types within this vector.
- df$Dim1etc contain a expression value for each gene in various biological samples.
I am trying to set up a loop (or otherwise), which add a new row to df summing up df$dim.1 , df$dim.2 etc for every unique value in df$gene_type. For the pictured example, the 10th row would look like,
df[10, 3] <- c("total", "antisense", "sum of Dim.1 values").
Then the code will find the next unique value in gene_type and sum Dim.1, Dim.2 etc for the new gene_type.

 
    