December 2017
Beginner to intermediate
470 pages
12h 29m
English
As often happens, we want to work on some code we had already created to add more features. In this case, we want to add a third dimension to the graphs using colors. We want to be able to specify a color variable that will be used to further divide the data in the graph.
To accomplish this, we add a color parameter to the function's signature using the "NULL check" pattern and we add the corresponding parameter in each case. Adding the parameter directly in the aes_string() function is not problematic in case of NULL because NULL values indicate to ggplot() we don't want to use a fill color for the graph.
However, note that we are not able to use the same technique with y . Instead, we check whether we ...