search for: zapsmall

Displaying 20 results from an estimated 69 matches for "zapsmall".

2023 Dec 16
1
zapsmall(x) for scalar x
I was quite suprised to discover that applying `zapsmall` to a scalar value has no apparent effect. For example: > y <- 2.220446e-16 > zapsmall(y,) [1] 2.2204e-16 I was expecting zapsmall(x)` to act like > round(y, digits=getOption('digits')) [1] 0 Looking at the current source code, indicates that `zapsmall` is expecting a vect...
2023 Dec 17
1
zapsmall(x) for scalar x
Zapping a vector of small numbers to zero would cause problems when printing the results of summary(). For example, if zapsmall(c(2.220446e-16, ..., 2.220446e-16)) == c(0, ..., 0) then print(summary(2.220446e-16), digits = 7) would print Min. 1st Qu. Median Mean 3rd Qu. Max. 0 0 0 0 0 0 The same problem can also appear when printing the results of summary.g...
2023 Dec 17
2
[External] Re: zapsmall(x) for scalar x
I think what's been missed is that zapsmall works relative to the absolute largest value in the vector. Hence if there's only one item in the vector, it is the largest, so its not zapped. The function's raison d'etre isn't to replace absolutely small values, but small values relative to the largest. Hence a vector of similar...
2023 Dec 17
1
zapsmall(x) for scalar x
...your thoughts and you change the world. --Dr. Norman Vincent Peale > On Dec 17, 2023, at 12:11?AM, Steve Martin <stevemartin041 at gmail.com> wrote: > > ?Zapping a vector of small numbers to zero would cause problems when > printing the results of summary(). For example, if > zapsmall(c(2.220446e-16, ..., 2.220446e-16)) == c(0, ..., 0) then > print(summary(2.220446e-16), digits = 7) would print > Min. 1st Qu. Median Mean 3rd Qu. Max. > 0 0 0 0 0 0 > > The same problem can also appear when printing t...
2023 Dec 18
1
[External] Re: zapsmall(x) for scalar x
Le 17/12/2023 ? 18:26, Barry Rowlingson a ?crit?: > I think what's been missed is that zapsmall works relative to the absolute > largest value in the vector. Hence if there's only one > item in the vector, it is the largest, so its not zapped. The function's > raison d'etre isn't to replace absolutely small values, > but small values relative to the largest. Hence...
2023 Dec 18
1
[External] Re: zapsmall(x) for scalar x
>>>>> Serguei Sokol via R-devel >>>>> on Mon, 18 Dec 2023 10:29:02 +0100 writes: > Le 17/12/2023 ? 18:26, Barry Rowlingson a ?crit?: >> I think what's been missed is that zapsmall works relative to the absolute >> largest value in the vector. Hence if there's only one >> item in the vector, it is the largest, so its not zapped. The function's >> raison d'etre isn't to replace absolutely small values, >> but small values...
2023 Dec 18
1
[External] Re: zapsmall(x) for scalar x
...e a function of x and the NA values of x? I can't think of a case where it would be used on anything but the non-NA values of x. I think it would be easier to specify a different mFUN() (and document this new argument) if the function has one argument and is applied to the non-NA values of x. zapsmall <- function(x, digits = getOption("digits"), mFUN = function(x) max(abs(x)), min.d = 0L ) { if (length(digits) == 0L) stop("invalid 'digits'") if (all(ina <- is.na(x))) return(x) mx <- mFUN(x[!ina]) round(x, digits = i...
2023 Dec 18
1
[External] Re: zapsmall(x) for scalar x
Le 18/12/2023 ? 11:24, Martin Maechler a ?crit?: >>>>>> Serguei Sokol via R-devel >>>>>> on Mon, 18 Dec 2023 10:29:02 +0100 writes: > > Le 17/12/2023 ? 18:26, Barry Rowlingson a ?crit?: > >> I think what's been missed is that zapsmall works relative to the absolute > >> largest value in the vector. Hence if there's only one > >> item in the vector, it is the largest, so its not zapped. The function's > >> raison d'etre isn't to replace absolutely small values, > &...
2023 Dec 19
1
[External] Re: zapsmall(x) for scalar x
...an't think of a case where it would be used on anything but the non-NA > values of x. > I think it would be easier to specify a different mFUN() (and document this > new argument) if the function has one argument and is applied to the non-NA > values of x. > zapsmall <- function(x, > digits = getOption("digits"), > mFUN = function(x) max(abs(x)), > min.d = 0L) { > if (length(digits) == 0L) > stop("invalid 'digits'") > if (all(ina <- is.na(x))) >...
2003 Oct 13
1
zapsmall with all values small (PR#4554)
Hi If all values are small, zapsmall does not zap. For example ... > zapsmall(1e-24) [1] 1e-24 > zapsmall(1e-24, digits=3) [1] 1e-24 Problem appears to be in calculation of digits ... mx <- max(abs(x[!ina])) digits = if (mx > 0) max(0, digits - log10(mx)) else d...
2005 Mar 29
1
zapsmall (PR#7755)
Full_Name: Paul Vos Version: 2.0.1 OS: windows XP Submission from: (NULL) (150.216.148.20) > zapsmall(.3-.2-.1,digits=7) [1] -2.775558e-17 This should be zero. By changing the condition if (mx > 0) in zapsmall to if (mx > 1) we get > zapsmall(.3-.2-.1,digits=7) [1] 0
2023 Jul 07
1
printCoefmat() and zap.ind
...t;0.600200", which are misleading because, if rounded to > the 6th decimal place, the values to be displayed should > be "0.502122" and "0.600162". > Is this behavior of printCoefmat() intended/normal? Yes, this is "normal" in the sense that zapsmall() is used. I'm not even sure anymore if I was always aware 1998 what exactly the simple zapsmall() function is doing. It does not do what you want here (and actually *typically* want for formatting numbers for display, plotting, etc): You "really want" here and in such situations z...
2008 Aug 18
1
trying to mimic page 70 of Software for Data Analysis
I was trying to do what is on page 70 of John Chambers' new book namely using trace to invoke the browser by doing trace(zapsmall, edit = TRUE) but , typing above at an R prompt, I get trace(zapsmall, edit=TRUE) sh: EMACS: command not found Error in edit(name, file, title, editor) : problem with running editor EMACS I looked in the archives but maybe it's a problem with the keywords I was using. If anyone could t...
2008 Aug 04
1
simulate data based on partial correlation matrix
...cbind( rbind( cor1, z=c(.5,.3,.1,.05) ), z=c(.5,.3,.1,.05,1) ) # create new matrix m4 <- m3 %*% chol(cor2) # uncenter and unscale m5 <- sweep( m4, 2, attr(m2, 'scaled:scale'), '*') m5 <- sweep( m5, 2, attr(m2, 'scaled:center'), '+') ##Check they are equal zapsmall(cor(m5))==zapsmall(cor2) Thanks, ben
2003 May 14
1
Multiple comparison and lme (again, sorry)
...let's assume I can live with "only approximations". In another thread, Thorsten Hothorn suggested for glm (slightly edited) library(multcomp) set.seed(290875) # a factor at three levels group <- factor(c(rep(1,10), rep(2, 10), rep(3,10))) # Williams contrasts contrasts(group)<-zapsmall(mginv(contrMat(table(group), type="Will"))) # a binary response z <- factor(rbinom(30, 1, 0.5)) # estimate the model gmod <- glm( z ~ group, family=binomial(link = "logit")) summary(gmod) # exclude the intercept # Should be the following, but does not work due to a confir...
2002 Oct 29
1
pretty not pretty
Hi, I have a following vector: > smallch [1] 0.0652840 0.1181300 0.0319370 0.0155700 0.0464110 0.0107850 [7] 0.0158970 0.0375900 0.0603090 0.0310300 0.0105920 0.0540580 [13] -0.0177740 0.0039393 Pretty (R 1.5.1) has problems with zero: > pretty(smallch) [1] -2.000000e-02 -3.469447e-18 2.000000e-02 4.000000e-02 6.000000e-02 [6] 8.000000e-02 1.000000e-01 1.200000e-01
2002 Jun 14
0
pretty() sometimes isn't
...[6] 6.000000e-01 8.000000e-01 Well that may not be a "bug", but it has this unfortunate consequence: R> pretty(c(-.4,.8)) [1] -4.000000e-01 -2.000000e-01 5.551115e-17 2.000000e-01 4.000000e-01 [6] 6.000000e-01 8.000000e-01 And thus my plot axes look funny unless I apply zapsmall: R> plot(c(-.4,.8), c(-.4,.8), axes=F) R> axis(1, at=pretty(c(-.4,.8))) # Yuck! R> axis(2, at=zapsmall(pretty(c(-.4,.8)))) # Better! So here's my simple suggestion: change the last line of pretty() from: seq(z$l, z$u, length = z$n + 1) to: zapsmall(seq(z$l, z$u...
2002 Oct 29
1
pretty not pretty
Hi, I have a following vector: > smallch [1] 0.0652840 0.1181300 0.0319370 0.0155700 0.0464110 0.0107850 [7] 0.0158970 0.0375900 0.0603090 0.0310300 0.0105920 0.0540580 [13] -0.0177740 0.0039393 Pretty (R 1.5.1) has problems with zero: > pretty(smallch) [1] -2.000000e-02 -3.469447e-18 2.000000e-02 4.000000e-02 6.000000e-02 [6] 8.000000e-02 1.000000e-01 1.200000e-01
2013 Nov 07
1
problem with interaction in lmer even after creating an "interaction variable"
Dear all, I have a problem with interactions in lmer. I have 2 factors (garden and gebiet) which interact, plus one other variable (home), dataframe arr. When I put: / lmer (biomass ~ home + garden:gebiet + ( 1|Block), data = arr)/ it writes: /Error in lme4::lFormula(formula = biomass ~ home + garden:gebiet + (1 | : rank of X = 28 < ncol(X) = 30/ In the lmer help I found out that if not
2023 Jul 06
1
printCoefmat() and zap.ind
Hi All, I would like to ask two questions about printCoefmat(). First, I found a behavior of printCoefmat() that looks strange to me, but I am not sure whether this is an intended behavior: ``` r set.seed(5689417) n <- 10000 x1 <- rnorm(n) x2 <- rnorm(n) y <- .5 * x1 + .6 * x2 + rnorm(n, -0.0002366, .2) dat <- data.frame(x1, x2, y) out <- lm(y ~ x1 + x2, dat) out_summary <-