I am stuck with something simple: I have vector of minutes and seconds like, e.g., myvec=c("10:56","2:32","0:00","0:00","62:59","60:40","46:23")
. Here the number before the :
notes the minutes and after the colon we have the seconds.
I tried
difftime(myvec,format='%M:%S')
Error in difftime(myvec, format = "%M:%S") :
unused argument (format = "%M:%S")
however my problem seems to be that some minutes values are bigger than 60. I am a bit startled that I can't think of any straightforward solution. Maybe I just misunderstood the difftime
documentation. Sorry if this creates a duplicate.
EDIT:
Since some people asked:
as.difftime(myvec,format='%M:%S',units='mins')
10.933333 2.533333 0.000000 0.000000 NA NA 46.383333
Instead of the two NAs I want the command to return something like 62.9999 60.6666
. At this point I am just curious whether there is any solution without using regex.