I have created a chart in ggplot2 using data from the gapminder package in RStudio. I am curious how to convert the horizontal axis to log scale. I did use the function scale_x_continuous but after running the code the graph disappears.
ggplot(data = gapminder07) + geom_point(mapping = aes(x = gdpPercap, y = lifeExp))
p <- ggplot(gapminder07, aes(x = gdpPercap, y=lifeExp, label = country))
p + geom_text()
p + scale_x_continuous(trans = 'log10')
Edit* The same issue occurs when adding a fitted line. The line appears but the data points disappear.
ggplot(data = gapminder07) + geom_point(mapping = aes(x = gdpPercap, y = lifeExp))
p <- ggplot(gapminder07, aes(x = gdpPercap, y=lifeExp, label = country))
p + geom_text()
p + geom_smooth()