Skip to content

meaning of lubridate setdiff

2 messages · Daniel Murphy, Garrett Grolemund

#
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:
[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?")