Go to TogaWare.com Home Page. Data Science Desktop Survival Guide
by Graham Williams
Duck Duck Go



CLICK HERE TO VISIT THE UPDATED SURVIVAL GUIDE

Bar Chart Supplied Values

20200427

\includegraphics[width=\textwidth]{figures/onepager/ggplot2:basic_bar_chart-1}

ds %>%
  count(wind_dir_9am) %>%
  ggplot(aes(x=wind_dir_9am, y=n)) +
  geom_col() +
  scale_y_continuous(labels=comma) +
  labs(x=vnames["wind_dir_9am"], y="Count")

If the values of the bars are supplied in the source dataset (the y-axis) ggplot2::geom_col() is used. In this example we manually count the frequency of each wind direction in the dataset prior to invoking ggplot2::ggplot(). This modified dataset is then passed on to ggplot2::ggplot() to display. Of course, it would be better in this specific example to let ggplot2::geom_bar() do the work itself as in Section 10.8.


Support further development by purchasing the PDF version of the book.
Other online resources include the GNU/Linux Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 2000-2020 Togaware Pty Ltd. . Creative Commons ShareAlike V4.