0

I have a dataset, df1

 Length  Duration
  90     10
  90     3
  90     5
  80     2
  80     2

I need to groupby Length and then sum

I am thinking I will have to

 library(dplyr)

  df1 %>%
  Group_by(df1$Length) %>%
  Sum(df1$Duration)

Desired Output:

Length    Sum

90         18      
80         4

dput

structure(list(Duration = c(10L, 3L, 5L, 2L, 2L), Length = c(90L, 
90L, 90L, 80L, 80L)), class = "data.frame", row.names = c(NA, 
-5L))
Lynn
  • 4,292
  • 5
  • 21
  • 44

0 Answers0