LoslegenKostenlos loslegen

The plot title thickens

Congrats on making it to the last exercise in the course! You'll now use your knowledge of rlang to define a function to customize a ggplot2 scatterplot. The function will allow for a title to be produced automatically based on the inputted values of the function. Try it out!

The rlang package has also been loaded for you in this exercise.

Diese Übung ist Teil des Kurses

Programming with dplyr

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Define custom function
my_scatter <- function(df, x_var, y_var, color_var) {
  ggplot(df, aes(x = ___, y = ___)) +
    geom_point(aes(color = ___)) +
    ggtitle(paste(___(enquo(y_var)), 
                  "versus", 
                  as_label(___(x_var)),
                  "with colors by", 
                  ___(___(color_var))))
}
Code bearbeiten und ausführen