0

I have a data df as shown below.

  • df$gene_name contains names of genes, each row is a unique identifier.
  • df$gene_type indicates the gene type, there are several types within this vector.
  • df$Dim1 etc 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.

enter image description here

Darren Tsai
  • 32,117
  • 5
  • 21
  • 51

0 Answers0