Scales and transformations in ggplot2 0.9.0

Some R code designed for ggplot2 0.8.9 is not compatible with ggplot2 0.9.0, and today the ggplot2 web site has outdated documentation which gives this broken example:

> x <- rnorm(10) * 100000 
> y <- seq(0, 1, length = 10) 
> p <- qplot(x, y) 
> p + scale_y_continuous(formatter = "percent")
Error in continuous_scale(c("y", "ymin", "ymax", "yend", "yintercept",  : 
  unused argument(s) (formatter = "percent")

Dennis Murphy points to the ggplot2 0.9.0 transition guide from where I derived a solution:

require(scales)
p <- qplot(x, y) 
p + scale_y_continuous(labels=percent)

The transition guide has more details about transformations such as log, log10, sqrt, etc. and formats such as comma, percent, dollar, date, scientific, etc.

About these ads
This entry was posted in Bugs and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s