Skip to content

Commit

Permalink
minor readability plus
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@471 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
maechler committed Dec 18, 1997
1 parent f92f984 commit c033891
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/library/base/R/cut
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cut <- function (x, breaks, labels=NULL, right=TRUE, dig.lab=3)
if (length(breaks) == 1) {
if (is.na(breaks) | breaks < 2)
stop("invalid number of intervals")
nb <- breaks + 1# one more than #{intervals}
nb <- as.integer(breaks + 1)# one more than #{intervals}
dx <- diff(rx <- range(x,na.rm=TRUE))
if(dx==0) dx <- rx[1]
breaks <- seq(rx[1] - dx/1000,
Expand All @@ -23,12 +23,12 @@ cut <- function (x, breaks, labels=NULL, right=TRUE, dig.lab=3)
else paste("Range", 1:(nb - 1),sep="_")
} else if (length(labels) != nb-1)
stop("labels/breaks length conflict")
codes <- .C(if(right) "bincode2" else "bincode",
as.double(x),
length(x),
as.double(breaks),
length(breaks),
integer(length(x)),
TRUE)[[5]]
factor(codes, seq(labels), labels)
code <- .C(if(right) "bincode2" else "bincode",
as.double(x),
length(x),
as.double(breaks),
nb,
code= integer(length(x)),
NAOK= TRUE) $code
factor(code, seq(labels), labels)
}

0 comments on commit c033891

Please sign in to comment.