In R, we can use dplyr. We separate (from tidyr), the 'status' into two new columns ('section', 'question') based on the space delimiter, then grouped by 'can.id' and 'section', get the sum of 'marks'.