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

Closed
mmuurr opened this Issue Apr 23, 2015 · 1 comment

Comments

Projects
None yet
1 participant
@mmuurr

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.

example:

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.
unique(ints)
## [1] 86400
@mmuurr

This comment has been minimized.

Show comment
Hide comment
@mmuurr

mmuurr 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...
factor(ints)
## [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))

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...
factor(ints)
## [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