[R] I have a problem with the log2 function
A.J. Rossini
rossini at blindglobe.net
Wed Oct 29 14:24:26 CET 2003
Frank Mattes <f.mattes at ucl.ac.uk> writes:
> Dear R users,
>
> according the help(log), the function
> log2(x) should give the natural logarithm of x.
>
> I expect in case of x=2 to to get 0.6931, however, R gives me 1 as a result.
>
> Similar, logb(2,2) gives 1 again.
>
> I'm wondering if I have missed something ?
>
I think you are looking at the help page wrong:
Description:
'log' computes natural logarithms, 'log10' computes common (i.e.,
base 10) logarithms, and 'log2' computes binary (i.e., base 2)
logarithms. The general form 'logb(x, base)' computes logarithms
with base 'base' ('log10' and 'log2' are only special cases).
'log1p(x)' computes log(1+x) accurately also for |x| << 1 (and
less accurately when x is approximately -1).
'exp' computes the exponential function.
'expm1(x)' computes exp(x) - 1 accurately also for |x| << 1.
log() is what you want.
--
rossini at u.washington.edu http://www.analytics.washington.edu/
Biomedical and Health Informatics University of Washington
Biostatistics, SCHARP/HVTN Fred Hutchinson Cancer Research Center
UW (Tu/Th/F): 206-616-7630 FAX=206-543-3461 | Voicemail is unreliable
FHCRC (M/W): 206-667-7025 FAX=206-667-4812 | use Email
CONFIDENTIALITY NOTICE: This e-mail message and any attachme...{{dropped}}
More information about the R-help
mailing list