[Rd] Small change to "cut.default"

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Wed, 14 Nov 2001 10:21:15 +0100


>>>>> "JonR" == Jonathan Rougier <J.C.Rougier@durham.ac.uk> writes:

    JonR> Hi everyone, Can I suggest the following cosmetic change to
    JonR> cut.default (R-1.3.1), to adjust the labels in the case that
    JonR> include.lowest = TRUE:

    .....

    JonR> Thus we have (noticing the labels)

    >> pp <- rpois(10, lambda = 1) breaks <- c(0:2, Inf) 
    >> cut(pp, breaks =breaks)
    JonR>  [1] NA (0,1] (0,1] (0,1] NA NA NA (0,1] (1,2] (1,2]
    JonR>  Levels: (0,1] (1,2] (2,Inf]
    >> cut(pp, breaks = breaks, include.lowest = TRUE)
    JonR>  [1] [0,1] [0,1] [0,1] [0,1] [0,1] [0,1] [0,1] [0,1] (1,2] (1,2]
    JonR> Levels: [0,1] (1,2] (2,Inf]
    >> cut(pp, breaks = breaks, include.lowest = TRUE, right = FALSE)
    JonR>  [1] [0,1) [1,2) [1,2) [1,2) [0,1) [0,1) [0,1) [1,2) [2,Inf] ..
    JonR> Levels: [0,1) [1,2) [2,Inf]
    >> cut(pp, breaks = breaks, right = FALSE)
    JonR>  [1] [0,1) [1,2) [1,2) [1,2) [0,1) [0,1) [0,1) [1,2) [2,Inf) ..
    JonR>  Levels: [0,1) [1,2) [2,Inf)

which sounds very reasonable.

There is the slight chance to break old code however for people who made
explicit use of the factor levels in things like

  indhigh  <-  fp == "[2, Inf)"

I still believe we should do the change for 1.4.
If there won't be further voices, I'll do.

Martin Maechler <maechler@stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO D10	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._