The base R function cut.POSIXt has a bug that cannot cut datetime into a number of intervals if the interval value are in-between input values. I sent email to r-devel and discussed the details in lubridateissue.
Now I just extracted a part of cut.R into a new function and wrote a proper cut for my need.
I found the breaks generated from cut are very useful, but the original cut just give you a certain format of breaks as labels, which make a lot of things awkward those labels are not enough. I have saw people asking how to get the breaks value, and the answer used regular expression to parse the number from labels!
Now with the breaks value I can do a lot of things much easier:
all distance/speed values start from 0, but the breaks will start from negative values by default to include the leftmost value, which doesn't quite make sense in our case. So I need to shift the breaks a little bit.
I need to format the labels with unit, so I need the breaks value instead of the limited label from cut by default.
The base R function
cut.POSIXt
has a bug that cannot cut datetime into a number of intervals if the interval value are in-between input values. I sent email tor-devel
and discussed the details inlubridate
issue.Now I just extracted a part of
cut.R
into a new function and wrote a proper cut for my need.I found the breaks generated from
cut
are very useful, but the originalcut
just give you a certain format of breaks as labels, which make a lot of things awkward those labels are not enough. I have saw people asking how to get the breaks value, and the answer used regular expression to parse the number from labels!Now with the breaks value I can do a lot of things much easier:
cut
by default.