[R] <NA> from cut.Date
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Sep 17 13:31:34 CEST 2014
On 17/09/2014 12:04, Benjamin Tyner wrote:
> Hello,
>
> I'm wondering if this is expected?
It is as documented!
>
> > cut(structure(11111, class="Date"), structure(c(11100,11111),
> class="Date"))
> [1] <NA>
> Levels: 2000-05-23
>
> The help page says that "for ‘"Date"’ objects, only ‘"day"’, ‘"week"’,
> ‘"month"’, ‘"quarter"’ and ‘"year"’ are allowed" [for the 'breaks'
> argument]. Though I am not sure whether this statement is only
> applicable in the context of the previous sentence about interval
> specification (i.e., a roundabout way of saying that ‘"sec"’, ‘"min"’,
> ‘"hour"’, and ‘"DSTday"’ are not allowed for 'Date' objects), or whether
> it also means that a vector of cut points (as in my example) is likewise
> not allowed? If the latter, then perhaps the function out to error out
> rather than return <NA> in this case?
The NA is correct: the value you pass is not covered by the 'breaks' you
specified. As the help says
Using both ‘right = TRUE’ and ‘include.lowest = TRUE’ will include
both ends of the range of dates.
With the default values, only the lower end is included.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK
More information about the R-help
mailing list