matloff / TidyverseSkeptic

An opinionated view of the Tidyverse "dialect" of the R language.
514 stars 45 forks source link

Quick histograms in ggplot2 #31

Open Aariq opened 2 years ago

Aariq commented 2 years ago

https://github.com/matloff/TidyverseSkeptic/blob/2c813c21090f10d3e30d83d2bf0ee4cb4b6331af/README.md?plain=1#L147

For a simple, quick histogram without any tweaks I'd go with qplot(Nile). If you keep the geom_histogram() example in, there's a mistake. Should be: ggplot(dn) + geom_histogram(aes(Nile)) without the dn in geom_histogram()

library(ggplot2)
qplot(Nile)
#> Don't know how to automatically pick scale for object of type ts. Defaulting to continuous.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Created on 2022-04-04 by the reprex package (v2.0.1)

matloff commented 1 year ago

Right. In my essay, I say: "(Things would be simpler for Tidy instructors if they were to use qplot() in the ggplot2 package, but as far as I know, few if any Tidy courses do this.)" Actually, this is a part of the Tidy story that still mystifies me; why don't they use qplot()?