gf_bar()

gf_bar()

The gf_bar() function creates a bar graph. It can be used to visualize the distribution of a categorical variable by counting the number of observations for each group of the category.

Bar graphs can also be used with the gf_facet_grid() function.

Idea
Example 1:

gf_bar( ~ Gender , data = Fingers )

Example of output from running the code above:
Bar plot of Gender from the Fingers data frame.

Idea
Example 2:

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.