Hi everyone,
Can I suggest the following cosmetic change to cut.default (R-1.3.1), to
adjust the labels in the case that include.lowest = TRUE:
arrow:dma0jcr% diff -u cut.R my.cut.R
--- cut.R Tue Nov 13 12:28:35 2001
+++ my.cut.R Tue Nov 13 12:35:16 2001
@@ -25,6 +25,11 @@
ch.br[-nb], ",", ch.br[-1],
if(right)"]" else ")",
sep='')
else paste("Range", 1:(nb - 1),sep="_")
+ if (ok && include.lowest)
+ if (right)
+ labels[1] <- gsub("^\\(", "\\[",
labels[1])
+ else
+ labels[nb-1] <- gsub("\\)$",
"\\]",
labels[nb-1])
} else if (is.logical(labels) && !labels)
codes.only <- TRUE
else if (length(labels) != nb-1)
Thus we have (noticing the labels)
> pp <- rpois(10, lambda = 1)
> breaks <- c(0:2, Inf)
> cut(pp, breaks = breaks)
[1] NA (0,1] (0,1] (0,1] NA NA NA (0,1] (1,2] (1,2]
Levels: (0,1] (1,2] (2,Inf] > cut(pp, breaks = breaks, include.lowest = TRUE)
[1] [0,1] [0,1] [0,1] [0,1] [0,1] [0,1] [0,1] [0,1] (1,2] (1,2]
Levels: [0,1] (1,2] (2,Inf] > cut(pp, breaks = breaks, include.lowest = TRUE, right = FALSE)
[1] [0,1) [1,2) [1,2) [1,2) [0,1) [0,1) [0,1) [1,2)
[2,Inf]
[10] [2,Inf]
Levels: [0,1) [1,2) [2,Inf] > cut(pp, breaks = breaks, right = FALSE)
[1] [0,1) [1,2) [1,2) [1,2) [0,1) [0,1) [0,1) [1,2)
[2,Inf)
[10] [2,Inf)
Levels: [0,1) [1,2) [2,Inf)
Cheers, Jonathan.
--
Jonathan Rougier Science Laboratories
Department of Mathematical Sciences South Road
University of Durham Durham DH1 3LE
tel: +44 (0)191 374 2361, fax: +44 (0)191 374 7388
http://www.maths.dur.ac.uk/stats/people/jcr/jcr.html
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._