gf_facet_grid()

gf_facet_grid()

The gf_facet_grid() function will create separate plots for each group of a categorical variable. It can be chained onto plots such as gf_histogram(), gf_jitter(), and gf_bar().

Idea
Example 1:

# Density histogram of Thumb faceted by Gender

gf_dhistogram( ~ Thumb , data = Fingers ) %>%

      gf_facet_grid( Gender ~ . )


Example of output from running the code above:

Density histograms of Thumb faceted by Gender in the Fingers data frame

Idea
Example 2:

# Bar plot of RaceEthnic faceted by Gender
gf_bar(~RaceEthnic, data = Fingers)%>%
      gf_facet_grid( Gender ~ . )

Example of output from running the code above:

Bar plot of RaceEthnic faceted by Gender in the Fingers data frame

Idea
Example 3:

# Jitter plot of Thumb by Height faceted by Gender
gf_jitter(Thumb ~ Height , data = Fingers ) %>%
      gf_facet_grid( Gender ~ . )

Example of output from running the code above:

Jitter plot of Thumb by Height faceted by Sex in the Fingers data frame