1

I am working on a problem set for ggplot2 in R. One of my questions asks for a scale log transformation, which both my notes and the Hadley Wickam book say can be done through this function:

scale_x_log()

However, when I use this function, R does not recognize it. Any time I use it, it gives me this error response:

Error: could not find function "scale_x_log" 

When I use the help function, "?scale_x_log", it returns this error message:

No documentation for ‘scale_x_log’ in specified packages and libraries:
you could try ‘??scale_x_log’

The "??scale_x_log" page takes me to "ggplot2::scale_x_continuous", which lists the function "scale_x_log10()". I am wondering if the function I am using doesn't exist, though this does not seem likely to me. I am also wondering if I need to download another package or something. I hope this question is clear....

1
  • 5
    I can't find any reference in the official documentation for scale_x_log. It seems your references are out of date. Did you want a log10 transformation? Then use scale_x_log10. Did you want a natural long transformation? use scale_x_continuous(trans = "log") Commented Jun 8, 2015 at 1:49

1 Answer 1

1

The book of Hadley is already quite old in regards to dynamics in programming. To my experience ggplot2 is quite a dynamic package and these details often change (also see questions referring to how to turn the labels on the axis). Due to that I prefer to check stuff like that on the ggplot website first. This website is kept up to date with all changes in ggplot functions and is also displaying all the plots given in the examples.
The general page can be found here and the specific page for the log scale here. Indeed you have to use the scale_x_log10() function now.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.