54

I'm plotting a fairly simple chart using ggplot2 0.9.1.

x <- rnorm(100, mean=100, sd = 1) * 1000000
y <- rnorm(100, mean=100, sd = 1) * 1000000
df <- data.frame(x,y)

p.new <- ggplot(df,aes(x,y)) +
  geom_point()
print(p.new)

Which works, but ggplot2 defaults to scientific notation that is inappropriate for my audience. If I want to change the x-axis label format by entering:

p.new + scale_x_continuous(labels = comma)

I get:

Error in structure(list(call = match.call(), aesthetics = aesthetics, : object 'comma' not found

What am I doing wrong? I note that the language changed recently from "formatter" to "labels". Perhaps I'm misreading the man page?

Edit: I was indeed misreading the man page

Need to load library(scales) before attempting this.

4

3 に答える 3

67

library(scales)これを試みる前にロードする必要があります。

于 2012-08-16T21:24:10.567 に答える