[R] Log plus one transformation in R

William Dunlap wdunlap at tibco.com
Mon Dec 12 17:37:29 CET 2016


log1p(x), in the base package computes log(1+x) accurately for small x (and
large).

E.g.,
> options(digits=16)
> base::log1p(1e-14)
[1] 9.99999999999995e-15
> base::log1p(1e-14) - base::log(1+1e-14)
[1] 7.992778373591124e-18
> as.numeric(log(Rmpfr::mpfr(1,precBits=1000) + Rmpfr::mpfr(1e-14,
precBits=1000))) - log1p(1e-14)
[1] 0


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Dec 12, 2016 at 8:23 AM, Faradj Koliev <faradj.g at gmail.com> wrote:

> Hi all,
>
> How do I perform log(x+1) in R?
>
> log1p_trans() from the package ”scales" doesn’t seem to work for me.
>
> Best,
> Faradj
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]



More information about the R-help mailing list