Combining results via arithmetic mean
Try it the R tidyverse way:

library(dplyr)
dfr &lt;- read.table(text = "id;attribute;time
A;AB;1
B;AB;2
C;AB;3
B;AB;4
B;AB;5
A;AB;6", header=TRUE, sep=";")

dfr %&gt;% group_by(id, attribute) %&gt;% summarize(mean=mean(time))


Result

# A tibble: 3 x 3
# Groups:   id [?]
      id attribute  mean
  &lt;fctr&gt;    &lt;fctr&gt; &lt;dbl&gt;
1      A        AB 3.500
2      B        AB 3.667
3      C        AB 3.000