[R] meaning of lubridate setdiff
Dan Murphy
chiefmurphy at gmail.com
Sun Feb 9 19:26:48 CET 2014
In the lubridate vignette
(http://cran.r-project.org/web/packages/lubridate/vignettes/lubridate.html)
setdiff(auckland, jsm)
results in
## [1] 2011-06-04 12:00:00 NZST--2011-07-20 NZST
But if Hadley's mentor had been called away earlier, say, July 31st,
wouldn't the set difference have resulted in two intervals? lubridate
shows one:
> jsm <- interval(ymd(20110720, tz = "Pacific/Auckland"), ymd(20110731, tz = "Pacific/Auckland"))
> setdiff(auckland, jsm)
[1] 2011-07-31 NZST--2011-07-20 NZST
i.e., the jsm interval in a negative direction (!).
That would not appear to be the intended meaning because the setMethod
code for "setdiff" seems to want to trap the two interval result:
if (length(makes2)) {
stop(paste("Cases", makes2,
"result in discontinuous intervals."))
}
but maybe I'm hastily misinterpreting the meaning of that check.
Thanks in advance for clarification.
- Dan
PS: (For the setdiff illustration, shouldn't the vignette be asking
"For what part of my visit will Chris *not* be there?")
More information about the R-help
mailing list