Harpal
Harpal

Reputation: 12587

Differences in log answers

I trying to attempt a log-log plot in R, but when I take the log of a particular value I do not get consistent answers, for example:

In R:
> log(192.4)
[1] 5.259577

On my phone:
2.28

On a web scientific calculator
I get: 2.2842050677018

What causes the inconsistencies between R and the other calculators? Which one would be the correct to use?

Scientific calculator i used.

Upvotes: 1

Views: 432

Answers (1)

Andrie
Andrie

Reputation: 179588

In common with many other programming languages, R calculates the natural logarithm, i.e. using base e with the function log(). If you want the base 10 logarithm, you need to use log10():

log(192.4)
[1] 5.259577


log10(192.4)
[1] 2.284205

This, and more, is documented in the help for ?log

Upvotes: 3

Related Questions