-3

I am trying to summarize this dataset by grouping by name (Almeria, Ath Bilbao,...) and have the sum of its corresponding values in column 2 (HalfTimeResult) and 3 (FullTimeResult). I tried with the aggregate and group_by functions but have not been able to obtain the right output.

What function and how would I use it to obtain an output like this?

enter image description here

This is the dataset that I am working with:

enter image description here

user2989902
  • 23
  • 1
  • 4

1 Answers1

-1

We can use data.table

library(data.table)
setDT(df1)[, lapply(.SD, sum), by = HomeTeam]
akrun
  • 874,273
  • 37
  • 540
  • 662