Description Usage Arguments Examples
Avoid -Inf
problems when x == 0
by setting a non-zero floor value for x
.
This is preferred over using some log(x + d)
transformation, as the choice of d
is
arbitrary, and will affect model fit.
1 |
x |
Numeric. |
floor |
Minimum age value boundary. Default |
1 2 3 4 5 6 7 8 9 10 11 12 | ## Not run:
x <- sample(0:400, 1e7, replace = TRUE)
floor <- 0.3
logFloor <- log(floor)
microbenchmark::microbenchmark(
log(pmax(floor, x)),
pmax(log(floor), log(x)),
{x[x < floor] <- floor; log(x)},
{y <- log(x); y[is.infinite(y)] <- logFloor} ## fastest; TODO: implement? not a bottleneck
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.