Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unique() for Interval? #315

mmuurr opened this Issue Apr 23, 2015 · 1 comment


None yet
1 participant
Copy link

mmuurr commented Apr 23, 2015

unique() doesn't appear to be defined for class Interval, yet it silently runs and produces results that (I think) don't make sense.


foo <- Sys.time() + days(1:4)
ints <- rep(interval(head(foo, -1), tail(foo, -1)), 2)
## each interval is the same _duration_, and unique(ints) simply returns the unique durations (in seconds).
## would (reasonably) expect the 3 unique _intervals_, instead.
## [1] 86400

This comment has been minimized.

Copy link

mmuurr commented Apr 23, 2015

quick add on why this could be useful: stratification by interval, e.g. by creating interval factors:

## continuing the example code from above...
## [1] <NA> <NA> <NA> <NA> <NA> <NA>
## Levels: 86400

foo <- data.frame(x = 1:6, ints = ints)
## if dlply-ing over ints, would expect a length-3 vector of 2s... instead it's a length-1 vector of 6:
unlist(dlply(foo, .(ints), nrow))

@vspinu vspinu closed this in 0e6bff4 Apr 23, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.