search for: zapsmall2

Displaying 6 results from an estimated 6 matches for "zapsmall2".

Did you mean: zapsmall
2023 Dec 19
1
[External] Re: zapsmall(x) for scalar x
...this change in the doc would clarify the situation but > > > would not resolve proposed corner cases. > > > > > I think that an additional argument 'mx' (absolute max value of > > > reference) would do. Consider: > > > > > zapsmall2 <- > > > function (x, digits = getOption("digits"), mx=max(abs(x), na.rm=TRUE)) > > > { > > > if (length(digits) == 0L) > > > stop("invalid 'digits'") > > > if (all(ina <- is.na(...
2023 Dec 18
1
[External] Re: zapsmall(x) for scalar x
...ead: > > " (compared with the maximal absolute value in the vector)" I agree that this change in the doc would clarify the situation but would not resolve proposed corner cases. I think that an additional argument 'mx' (absolute max value of reference) would do. Consider: zapsmall2 <- function (x, digits = getOption("digits"), mx=max(abs(x), na.rm=TRUE)) { ??? if (length(digits) == 0L) ??????? stop("invalid 'digits'") ??? if (all(ina <- is.na(x))) ??????? return(x) ??? round(x, digits = if (mx > 0) max(0L, digits - as.numeric(log10(m...
2023 Dec 18
1
[External] Re: zapsmall(x) for scalar x
...l absolute value in the vector)" > I agree that this change in the doc would clarify the situation but > would not resolve proposed corner cases. > I think that an additional argument 'mx' (absolute max value of > reference) would do. Consider: > zapsmall2 <- > function (x, digits = getOption("digits"), mx=max(abs(x), na.rm=TRUE)) > { > ??? if (length(digits) == 0L) > ??????? stop("invalid 'digits'") > ??? if (all(ina <- is.na(x))) > ??????? return(x) > ??? round(x, di...
2023 Dec 18
1
[External] Re: zapsmall(x) for scalar x
...change in the doc would clarify the situation > but > > > would not resolve proposed corner cases. > > > > > I think that an additional argument 'mx' (absolute max value of > > > reference) would do. Consider: > > > > > zapsmall2 <- > > > function (x, digits = getOption("digits"), mx=max(abs(x), > na.rm=TRUE)) > > > { > > > if (length(digits) == 0L) > > > stop("invalid 'digits'") > > > if (all(ina <- is...
2023 Dec 18
1
[External] Re: zapsmall(x) for scalar x
...t; > > I agree that this change in the doc would clarify the situation but > > would not resolve proposed corner cases. > > > I think that an additional argument 'mx' (absolute max value of > > reference) would do. Consider: > > > zapsmall2 <- > > function (x, digits = getOption("digits"), mx=max(abs(x), na.rm=TRUE)) > > { > > ??? if (length(digits) == 0L) > > ??????? stop("invalid 'digits'") > > ??? if (all(ina <- is.na(x))) > > ??????...
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 tiny values doesn't get zapped. Maybe the line