0

I have the data format:

          id   OB03A OB03B
          1     1     1
          1     0    NA
          1     1    NA
          1     0    NA
          2     0    NA
          2     1    NA

I am trying to add up all of the values of OB03A for each id, so for id 1 the sum should be 2, and for 2 it should be 1, etc. Is there a function that can do this? I have tried messing around with lapply and counting functions, but that feels too complicated. Is there a better solution?

The final dataframe should be one to one id to OB03A sum:

         id   OB03A OB03B
          1     2     1
          2     1    NA
          3     1    NA
User350178
  • 49
  • 8

0 Answers0