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
"?log" includes documentation for "log1p" in the base package Will that work? Spencer Graves On 12/12/2016 10:23 AM, Faradj Koliev 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.
Faradj, I all you need to do is newvalue <- log(x+1) John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing)>>> Faradj Koliev <faradj.g at gmail.com> 12/12/16 11:24 AM >>>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. Confidentiality Statement: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
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]]
>>>>> Faradj Koliev <faradj.g at gmail.com> >>>>> on Mon, 12 Dec 2016 17:23:20 +0100 writes:> Hi all, How do I perform log(x+1) in R? > log1p_trans() from the package ?scales" doesn?t seem to > work for me. amazing that you did not find log1p() in base R.
At the risk of being flamed . . . What is the difference between log1p(x) and log(x+1)? The two methods appear to give the same results:> log1p(0.000001)/log(0.000001+1)[1] 1 John John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing)>>> William Dunlap via R-help <r-help at r-project.org> 12/12/16 11:38 AM >>>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]] ______________________________________________ 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. Confidentiality Statement: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.