-1

am having exam dataframe with student.id marks

student.id  marks
     2         2
     2         2
     2        -1
     3        -1
     3        -1  
     3         2
     4         2
     4        -1
     5         2
     5         2
     5         2

how could i sum total marks for a specific student.id like below table

  student.id     total-marks
       2           
       3
       4
       5

how can i obtain the above table with respective total marks ? thanks

Apache11
  • 189
  • 11

1 Answers1

0

If you data.frame is callesd df, this should work:

 aggregate(marks~student.id,df,FUN="sum")
Otto_K
  • 347
  • 2
  • 6