mhhaney / r-base-graphics-and-ggplot2

A set of examples of various graphics created with base R graphics and/or the ggplot2 package. Created as a class project by the DSA400W - Data Visualization and Communication class at Chatham University, Fall 2021.
GNU General Public License v3.0
1 stars 15 forks source link

Revisions to diverging bar chart section #36

Open mhhaney opened 3 years ago

mhhaney commented 3 years ago

Add explanations to diverging bar chart and separate data manipulation code and plot code into separate code blocks. This plot plots z-scores, so z-scores and the calculation used to get the z-scores should be explained. Explain the ifelse() function that calculates the new variable fertility_type and how that variable then is used in the plot to determine the fill (color) of the bars.

Also can remove ticks around 'municipality'. Ticks are used when a variable name contains spaces, but it appears that Hannah revised the example to use different data, and the different data had variable names without the spaces, so the ticks can be removed. There is also a comment that refers to mpg. That comment should be revised.

Explain why the municipality is converted to a factor, with levels set to swiss$municipality (The levels sets the order. If we don't do that the municipalities, which are the x value, will be shown alphabetically. We want them to be ordered by z score).

Finally, explain how the scale_fill_manual() function gives control over the legend in this case.

If you can't figure out all of these do as many as you can.

hfierle commented 3 years ago

Since I did the diverging bar chart section I can work on this one as well, unless someone else needs an issue to work on and wants to take it.

mhhaney commented 3 years ago

This is a good one for you to do @hfierle