1

I am sure I am missing something simple but I have a data frame that looks like this:

   Genera  Species  t1 t2 t3 t4 t5
   g1      s1       0  0  1  3  1
   g1      s2       0  1  1  0  1
   g2      s3       1  2  0  1  0
   g2      s4       1  0  0  0  0

The first column is the genus name, the second a species name, and each column after that is some value record at different times.

I am trying to merge rows that have shared genera and sum the values in each subsequent column.

The final result should look like this:

   Genera t1 t2 t3 t4 t5
   g1     0  1  2  3  2
   g2     2  2  0  1  0

This is similar to a question asked by user3390169, but I have not been able to load my data frame in a way that makes the suggested solutions possible.

For example, I have tried removing the species information and turning the genus into row names, but R appends a unique number to each row name.

I am fairly new to R and any help would be appreciated!

Shawn
  • 1,232
  • 1
  • 14
  • 44

0 Answers0