[R] cut.POSIXt misconception/feature/bug?
diggsb at ohsu.edu
Thu Mar 11 20:52:55 CET 2010
On 3/10/2010 11:26 PM, Petr PIKAL wrote:
> Thanks for clarification. Actually I knew that with first case I get some
> data with NAs at the beginning and at the end. Maybe my English is not
> good enough to understand that to get vector of dates split to several
> chunks I need to put also end date and last date to get the whole vector.
> This is what help page for cut.POSIXt says about breaks and although I
> read it carefully I did not find any mention that at least 2 values are
> necessary. I did not connected it with information from cut help page,
> breaks: a vector of cut points _or_ number giving the number of
> which can be vector of length one. However thinking about it more
> thoroughly vector of length one is probably the same as one number with
> respect of its interpretation.
Since everything is a vector, even a single number is technically a vector of length 1. But that is a somewhat subtle point. I think the description from cut is better: "either a numeric vector of two or more cut points or a single number (greater than or equal to 2) giving the number of intervals into which x is to be cut"
> Therefore I also missed the clue that I need not only
> Using both ‘right = TRUE’ and ‘include.lowest = TRUE’ will
> include both ends of the range of dates.
> but also
> br<-dat[c(1, 23, 42,60)]
> To get the whole vector of cut dates without NAs in both ends.
> breaks: a vector of 2 or more cut points _or_ number giving the number
> Using both ‘right = TRUE’ and ‘include.lowest = TRUE’ together with
> starting and ending date will include both ends of the range of dates.
> could make help page more digestable.
I think that the comment in details has more to do with how to include the endpoints of breaks in the included ranges rather than the extremes of the dates (x). I think a better clarification would be to say "Using both ‘right = TRUE’ and ‘include.lowest = TRUE’ will include both ends of the range of breaks". That makes it clear that the dates that are referred to there are the breaks, not x.
> Thank you.
I've included a patch against cut.POSIXt.Rd with these proposed changes.
Brian Diggs, Ph.D.
Senior Research Associate, Department of Surgery, Oregon Health & Science University
More information about the R-help