I'm measuring the performance of several function in nested foreach loops, in order to do that
start <- Sys.time()
<corpus of function>
end <- Sys.time()
diff_time = end - start
The problem is that afterwords the object assumes the class "diff_time" and i've trouble plotting it with ggplot2.
It is possibile that some simulation that are quicker than others will have the suffix sec and others mins? If that occurs, how can i avoid these problems?
You can specify the units when converting the difftime to numeric.
t = difftime(time1 = "2016-01-02 01:00:00", time2 = "2016-01-02 00:30:00")
t
# Time difference of 30 mins
as.numeric(t, units = "secs")
# [1] 1800