Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upConvert Period to numeric #420
Comments
|
Ok, I found Stepping through the function, it works like a component getter. Shouldn't the behavior be similar to a I'm slightly confused between duration and period, but it's so convenient to use |
|
Sorry for coming late on this. Periods don't have a predefined length, hence the warning.
Yes. This makes sense indeed. |
This behavior is undocumented but I agree that it doesn't make sense. |
|
BTW, there is |
|
Fixing as.numeric and also removing all other Let me know if you see more problems of this kind. Thanks. |
|
One last thing. No need to sum up peridos. You can produce those in one go: per <- period(hours = 10, minutes = 6)
as.numeric(per, "hours")
# [1] 10.1 |
|
Great @vspinu, and many thanks for the period tip ! |
I couldn't find the right way to do it, but it seems hard to convert Period elements to numeric.
This is the expected behavior (
as.numericondifftime)However Period objects only return the
unitpart of the Period, like components getters (second,minute, ... )The trick I found was to convert to duration, but I get a warning when converting
Periodtoduration.