How to convert the time difference in minutes to R?

I have the following program:

timeStart<-Sys.time()
timeEnd<-Sys.time()
difference<-timeEnd-timeStart
anyVector<-c(difference)

in the end I need to put this data in a vector, the problem I have is than when the difference in seconds, this value looks like:

4.46809 seconds

and when it goes a few minutes, the values ​​will be like this:

2.344445 minutes

I would like the answer to be converted to minutes anyway, but when I do something like this:

anyVector<-c(difference/60)

for the case where the difference value in seconds works fine, but it also converts the data when it is in minutes, giving me the wrong number.

So, how can I convert to minutes only when the answer is in a few seconds, and not in a few minutes?

+4
source share
1 answer

difftime R:

timeStart<-Sys.time()
timeEnd<-Sys.time()

difference <- difftime(timeEnd, timeStart, units='mins')

> difference
Time difference of 0.1424748 mins

units mins, .

+8

All Articles