stephen@cogsci.ed.ac.uk
2002-Jan-15 16:12 UTC
[Rd] labels returned by cut() when include.lowest=T (PR#1263)
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
maechler@stat.math.ethz.ch
2002-Jan-15 17:07 UTC
[Rd] labels returned by cut() when include.lowest=T (PR#1263)
>>>>> "StEgl" == Stephen Eglen <stephen@cogsci.ed.ac.uk> writes:StEgl> Full_Name: Stephen Eglen StEgl> Version: 1.4 StEgl> OS: Redhat Linux 7.1 StEgl> Submission from: (NULL) (128.252.204.36) StEgl> I think the brackets in the levels of cut() are StEgl> slightly incorrect when include.lowest is TRUE. StEgl> For example: >> table(cut( c(1,4), include.lowest=T, right=F, breaks=c(1,2,3,4))) StEgl> [1,2) [2,3) [3,4) StEgl> 1 0 1 StEgl> I think the last range in this case should be [3,4]. A similar StEgl> problem exists for the first range when right=T. StEgl> Here is a possible patch against 1.4.0, which on the StEgl> above example gives: StEgl> [1,2) [2,3) [3,4] StEgl> 1 0 1 StEgl> 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) ------ Thank you. {I've fixed it using ``substring() <- '' instead of sub()}. Martin -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._