pcmathias / AACC-Introduction-to-R

Course content for How to Truly "Excel" at Data Analysis and Visualization: An Introduction to the R Programming Language
1 stars 1 forks source link

More beginner friendly ggplot code #11

Open nkrumm opened 5 years ago

nkrumm commented 5 years ago

Currently we have chunks such as:

g <-  ggplot(data, aes(x=method_a))
g <- g + geom_histogram(bins=50)
g

This is confusing (even to me) as the aesthetic should really be part of the geom_histogram. (I first realized this looking over Stephan's slides (03-exploring-data.pdf).

I would propose this re-write:

g <-  ggplot(data=data)
g <- g + geom_histogram(bins=50, aes(x=method_a))
g
pcmathias commented 5 years ago

Revised format: ggplot(data = data) + geom_histogram(mapping = aes(x = variable1))