Change column of minutes and seconds to only seconds in R dataframe

I have a dataset, df that is mixed with minutes as well as seconds. How would I convert this column to seconds only?

     duration    group

     5            1
     1.5          2
     5.2          3
     1            4
     0            5

I would like this output:

    duration    group

    5            1
    90           2
    312          3
     1           4
     0           5

I have tried:


  df % summarize ((df$duration)  units = "secs")

  I am not sure how to put this together,

Are you saying that it's a mix of seconds in a minutes in the same column? How do you distinguish which is which then?

This is an ofshoot of

Where the difftime as seconds issue has since been covered

1 Like

Yes. I see values of 1.16, 0, 5, 2.5, 1.11116 - the numbers with decimals are in minutes, the rest are in seconds

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.