[Rd] labels returned by cut() when include.lowest=T (PR#1263)
stephen@cogsci.ed.ac.uk
stephen@cogsci.ed.ac.uk
Tue, 15 Jan 2002 17:12:42 +0100 (MET)
Full_Name: Stephen Eglen
Version: 1.4
OS: Redhat Linux 7.1
Submission from: (NULL) (128.252.204.36)
I think the brackets in the levels of cut() are slightly incorrect when
include.lowest is TRUE.
For example:
> table(cut( c(1,4), include.lowest=T, right=F, breaks=c(1,2,3,4)))
[1,2) [2,3) [3,4)
1 0 1
I think the last range in this case should be [3,4]. A similar
problem exists for the first range when right=T.
Here is a possible patch against 1.4.0, which on the above example gives:
[1,2) [2,3) [3,4]
1 0 1
Stephen
*** /tmp/cut.R.orig716Cri Mon Jan 14 22:58:12 2002
--- /tmp/cut.R716P1o Mon Jan 14 22:58:12 2002
***************
*** 25,30 ****
--- 25,35 ----
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] <- sub("\\(", "\\[", labels[1])
+ else
+ labels[nb-1] <- sub(")", "]", labels[nb-1])
} else if (is.logical(labels) && !labels)
codes.only <- TRUE
else if (length(labels) != nb-1)
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._