I have repeated facet headers that I need to combine into a single header with the following sample data:
structure(list(Level1 = structure(c(1L, 1L, 1L, 1L, 1L), .Label =
"Repeated", class = "factor"), Level2 = structure(c(1L, 1L, 2L, 2L, 2L),
.Label = c("A", "B"), class = "factor"), Level3 = structure(1:5, .Label
= c("A", "B", "C", "D", "E"), class = "factor"), Value = c(6L, 2L, 3L,
4L, 0L)), .Names = c("Level1", "Level2", "Level3", "Value"), class =
"data.frame", row.names = c(NA, -5L))
I created a barplot with ggplot2 using facet_wrap() and set the number of columns to 1:
ggplot(data=samp, aes(x=reorder(Level3, Value), y=Value)) +
geom_bar(stat="identity") +
coord_flip() +
ylab("Value") +
xlab("Level3") +
facet_wrap(~Level1 + Level2, scales = 'free_y', ncol = 1)
I need to show the nesting for the Level3, Level2, and Level1 factors but without repeating any facet headers. Here the Level1 factor facet header is repeated.
I attempted to follow instructions from the post below, but could not figure out how to customize to my data: Nested facets in ggplot2 spanning groups
Any assistance is appreciated.