[Rd] argument order for Math2 group functions in R 2.6.x (PR#10679)
Jeffrey J. Hallman
jhallman at frb.gov
Wed Feb 6 17:25:40 CET 2008
You could always define your own signif() as
signif <- function(x, digits = 6){
base::signif(x, digits)
}
I do something like this for signif() and round() because economists don't
like the round-to-even convention R uses. My round() function, for example,
is:
round <- function(x, digits = 0, round.to.even = FALSE){
## Fixed to always round 0.5 to 1. The S "round to even" convention
## can be switched on via the round.to.even argument. -- JJH
xclass <- class(x)
if(is.matrix(x)){
digits <- rep(digits, length=ncol(x))
for(j in 1:ncol(x))
x[,j] <- round(x[,j], digits = digits[j], round.to.even = round.to.even)
}
else {
if(round.to.even)
return(base::round(x, digits))
ten.to.digits <- 10^digits
x <- trunc((x * ten.to.digits) + (sign(x[]) * 0.5))/ten.to.digits
}
class(x) <- xclass
return(x)
}
Sure, it's a lot slower. It still saves me several hours a year from not
having to explain what round-to-even does, and why my users should learn to
like it. They violently object to the idea that
1 + round(1.5) != round(1 + 1.5)
--
Jeff
More information about the R-devel
mailing list