Sorry, perhaps let me use the code below. Only p_addm gives a proper plot; p_medi gives an empty plot.
p_medi <- ggplot(ASD_State_MEDI, aes(x = 1, fill = State_Full2)) +
geom_bar() + theme(axis.text.x=element_blank(), # Hide axis
axis.ticks.x=element_blank(), # Hide axis
axis.text.y=element_blank(), # Hide axis
axis.ticks.y=element_blank(), # Hide axis
panel.background = element_blank(), # Remove panel background
legend.position="none",
strip.text.y = element_text(angle=0) # Rotate text to horizontal
) +
facet_grid(facets = State_Full2 ~ Year_Factor) +
labs(x="", y="", title="Years Data Available by State [ Source: MEDI ]") # layers of graphics
p_medi
p_addm <- ggplot(ASD_State_ADDM, aes(x = 1, fill = State_Full2)) +
geom_bar() + theme(axis.text.x=element_blank(), # Hide axis
axis.ticks.x=element_blank(), # Hide axis
axis.text.y=element_blank(), # Hide axis
axis.ticks.y=element_blank(), # Hide axis
panel.background = element_blank(), # Remove panel background
legend.position="none",
strip.text.y = element_text(angle=0) # Rotate text to horizontal
) +
facet_grid(facets = State_Full2 ~ Year_Factor) +
labs(x="", y="", title="Years Data Available by State [ Source: ADDM ]") # layers of graphics
p_addm
The dput for both MEDI and ADDM are:
> ASD_State_MEDI %>%
+ select(State_Full2,Year_Factor) %>%
+ slice(sample.int(n=nrow(ASD_State_MEDI),
+ size=50, replace = FALSE)) %>%
+ dput()
structure(list(State_Full2 = structure(c(34L, 12L, 49L, 49L,
48L, 50L, 11L, 9L, 15L, 2L, 46L, 15L, 17L, 12L, 3L, 47L, 9L,
47L, 2L, 45L, 29L, 29L, 15L, 20L, 33L, 32L, 50L, 25L, 27L, 15L,
7L, 9L, 3L, 8L, 28L, 30L, 6L, 9L, 37L, 41L, 3L, 50L, 40L, 2L,
19L, 38L, 18L, 50L, 43L, 26L), .Label = c("AK-Alaska", "AL-Alabama",
"AR-Arkansas", "AZ-Arizona", "CA-California", "CO-Colorado",
"CT-Connecticut", "DC-District of Columbia", "DE-Delaware", "FL-Florida",
"GA-Georgia", "HI-Hawaii", "IA-Iowa", "ID-Idaho", "IL-Illinois",
"IN-Indiana", "KS-Kansas", "KY-Kentucky", "LA-Louisiana", "MA-Massachusetts",
"MD-Maryland", "ME-Maine", "MI-Michigan", "MN-Minnesota", "MO-Missouri",
"MS-Mississippi", "MT-Montana", "NC-North Carolina", "ND-North Dakota",
"NE-Nebraska", "NH-New Hampshire", "NJ-New Jersey", "NM-New Mexico",
"NV-Nevada", "NY-New York", "OH-Ohio", "OK-Oklahoma", "OR-Oregon",
"PA-Pennsylvania", "RI-Rhode Island", "SC-South Carolina", "SD-South Dakota",
"TN-Tennessee", "TX-Texas", "UT-Utah", "VA-Virginia", "VT-Vermont",
"WA-Washington", "WI-Wisconsin", "WV-West Virginia", "WY-Wyoming"
), class = "factor"), Year_Factor = structure(c(10L, 7L, 12L,
11L, 12L, 7L, 11L, 2L, 2L, 7L, 1L, 11L, 3L, 4L, 8L, 12L, 6L,
3L, 5L, 10L, 3L, 8L, 13L, 1L, 1L, 1L, 12L, 13L, 9L, 7L, 2L, 13L,
4L, 9L, 6L, 5L, 7L, 7L, 3L, 13L, 6L, 5L, 10L, 3L, 4L, 12L, 6L,
6L, 7L, 12L), .Label = c("2000", "2001", "2002", "2003", "2004",
"2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012",
"2013", "2014", "2015", "2016"), class = c("ordered", "factor"
))), row.names = c(NA, -50L), class = "data.frame")
> ASD_State_ADDM %>%
+ select(State_Full2,Year_Factor) %>%
+ slice(sample.int(n=nrow(ASD_State_ADDM),
+ size=50, replace = FALSE)) %>%
+ dput()
structure(list(State_Full2 = structure(c(28L, 11L, 25L, 39L,
3L, 21L, 11L, 21L, 49L, 2L, 3L, 49L, 32L, 32L, 25L, 45L, 4L,
25L, 3L, 4L, 50L, 21L, 28L, 25L, 2L, 2L, 4L, 21L, 50L, 28L, 45L,
11L, 45L, 2L, 25L, 28L, 41L, 45L, 24L, 10L, 28L, 4L, 32L, 2L,
21L, 6L, 21L, 25L, 4L, 28L), .Label = c("AK-Alaska", "AL-Alabama",
"AR-Arkansas", "AZ-Arizona", "CA-California", "CO-Colorado",
"CT-Connecticut", "DC-District of Columbia", "DE-Delaware", "FL-Florida",
"GA-Georgia", "HI-Hawaii", "IA-Iowa", "ID-Idaho", "IL-Illinois",
"IN-Indiana", "KS-Kansas", "KY-Kentucky", "LA-Louisiana", "MA-Massachusetts",
"MD-Maryland", "ME-Maine", "MI-Michigan", "MN-Minnesota", "MO-Missouri",
"MS-Mississippi", "MT-Montana", "NC-North Carolina", "ND-North Dakota",
"NE-Nebraska", "NH-New Hampshire", "NJ-New Jersey", "NM-New Mexico",
"NV-Nevada", "NY-New York", "OH-Ohio", "OK-Oklahoma", "OR-Oregon",
"PA-Pennsylvania", "RI-Rhode Island", "SC-South Carolina", "SD-South Dakota",
"TN-Tennessee", "TX-Texas", "UT-Utah", "VA-Virginia", "VT-Vermont",
"WA-Washington", "WI-Wisconsin", "WV-West Virginia", "WY-Wyoming"
), class = "factor"), Year_Factor = structure(c(13L, 13L, 15L,
9L, 3L, 11L, 15L, 9L, 9L, 7L, 13L, 7L, 9L, 3L, 5L, 13L, 11L,
11L, 9L, 13L, 3L, 15L, 5L, 13L, 3L, 9L, 5L, 3L, 1L, 3L, 3L, 3L,
11L, 11L, 9L, 15L, 9L, 9L, 15L, 9L, 7L, 3L, 15L, 5L, 7L, 15L,
1L, 7L, 15L, 11L), .Label = c("2000", "2001", "2002", "2003",
"2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011",
"2012", "2013", "2014", "2015", "2016"), class = c("ordered",
"factor"))), row.names = c(NA, -50L), class = "data.frame")