LibraryCarpentry / lc-r

Introduction to R
http://librarycarpentry.org/lc-r/
Other
14 stars 28 forks source link

Data viz: reinforcing visualization labeling principles (lines 522-532) #21

Closed libjohn closed 3 years ago

libjohn commented 4 years ago

data viz lesson | [code @ lines 521-532](https://github.com/LibraryCarpentry/lc-r/blob/7d79490df929407480b122fb761fff9c30a4f7ff/_episodes_rmd/04-data-viz-ggplot.Rmd#L522

facet_wrap is introduced. I propose this is a great time to reinforce visualization principles that I suggested in issue 20...

Proposed

We can use `facet_wrap()` as a way of seeing our data across the categories of a single variable -- in this case the categories of the subCollection variable.  In this way, we highlight the number of formats per sub-collection. 

...{r purl=FALSE} # begin code chunk
ggplot(data = books2, aes(x = fct_rev(fct_infreq(subCollection)))) +
  geom_bar() +
  facet_wrap(~ format, nrow = 2) +
  scale_y_log10() +
  coord_flip() +
  labs(x = "Library subcollection", y = "")
... # end code chunk
libjohn commented 3 years ago

merged https://github.com/LibraryCarpentry/lc-r/pull/31