Greek letters in nested facets in ggplot2 - r

I have a huge dataset and I need to plot in facets with one nested facets in x axis(alpha and de id of replicate) and in y axis (beta)
fen_ale_all_rep$alpha <- factor(
fen_ale_all_rep$alpha,
levels = c("alpha 0.1", "alpha 0.2", "alpha 0.4", "alpha 0.8", "alpha 1.6"),
labels = c(
"alpha '0.1'",
"alpha '0.2'",
"alpha '0.4'",
"alpha '0.8'",
"alpha '1.6'"
)
)
fen_ale_rep5$beta <- factor(
fen_ale_rep5$beta,
levels = c(
"beta 0.05",
"beta 0.1",
"beta 0.2",
"beta 0.4",
"beta 0.8",
"beta 1.6",
"beta 3.2",
"beta 6.4",
"beta 12.8",
"beta 25.6",
"beta 51.2",
"beta 102.4"
),
labels = c(
"beta 0.05",
"beta 0.1",
"beta 0.2",
"beta 0.4",
"beta 0.8",
"beta 1.6",
"beta 3.2",
"beta 6.4",
"beta 12.8",
"beta 25.6",
"beta 51.2",
"beta 102.4"
)
)
structure:
tbl <- structure(list(FEN = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L), .Label = c("Plants", "Insects"), class = "factor"),
NSEL = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1), rep = c("rep 1", "rep 1", "rep 1", "rep 1",
"rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1",
"rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1",
"rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1",
"rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1",
"rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1",
"rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1",
"rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1",
"rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1", "rep 1"
), alpha = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L), .Label = c("alpha 0.1", "alpha 0.2",
"alpha 0.4", "alpha 0.8", "alpha 1.6"), class = "factor"),
beta = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L), .Label = c("beta 0.05", "beta 0.1",
"beta 0.2", "beta 0.4", "beta 0.8", "beta 1.6", "beta 3.2",
"beta 6.4", "beta 12.8", "beta 25.6", "beta 51.2", "beta 102.4"
), class = "factor"), TEMPO = c(1L, 200L, 400L, 600L, 800L,
1000L, 1200L, 1400L, 1600L, 1800L, 2000L, 2200L, 2400L, 2600L,
2800L, 3000L, 3200L, 3400L, 3600L, 3800L, 4000L, 4200L, 4400L,
4600L, 4800L, 5000L, 5200L, 5400L, 5600L, 5800L, 6000L, 6200L,
6400L, 6600L, 6800L, 7000L, 7200L, 7400L, 7600L, 7800L, 8000L,
8200L, 8400L, 8600L, 8800L, 9000L, 9200L, 9400L, 9600L, 9800L,
10000L, 1L, 200L, 400L, 600L, 800L, 1000L, 1200L, 1400L,
1600L), ab = c("0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05",
"0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05",
"0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05",
"0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05",
"0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05",
"0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05",
"0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05",
"0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05",
"0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05",
"0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05", "0.1 0.05",
"0.1 0.05", "0.1 0.05", "0.1 0.1", "0.1 0.1", "0.1 0.1",
"0.1 0.1", "0.1 0.1", "0.1 0.1", "0.1 0.1", "0.1 0.1", "0.1 0.1"
), especie = c("1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"1", "1", "1"), trait = c(0.59532188, 0.63023233, 0.59210289,
0.58660778, 0.55932657, 0.57032034, 0.56379332, 0.61973847,
0.61705717, 0.62310601, 0.61690676, 0.6508817, 0.64581712,
0.5890861, 0.66424559, 0.64007846, 0.52734623, 0.65276626,
0.57025516, 0.59734711, 0.59672837, 0.57971204, 0.51274562,
0.60679023, 0.56463537, 0.64716034, 0.60257023, 0.68582648,
0.62075915, 0.46707366, 0.65330306, 0.59301249, 0.70620201,
0.5260134, 0.51619464, 0.65620395, 0.48348558, 0.62189428,
0.60360017, 0.55274833, 0.56492948, 0.61039593, 0.75225962,
0.54349533, 0.47189362, 0.52454647, 0.56282583, 0.63985652,
0.58380379, 0.59214658, 0.73188778, 0.62808414, 0.59229323,
0.6978987, 0.61346245, 0.49995094, 0.4661158, 0.57436886,
0.58524132, 0.60717574)), row.names = c(NA, 60L), class = "data.frame")
I can produce this plot:
But, it doesn't show the replicate id. and the betas doesn't follow the crescent order.
I would like something like:
or one single facet with replicate and de columns with each alpha value (0.1,0.2,....)
for(i in 1:10) {
grid1 <- print(
ggplot(
fen_ale_all_rep,
aes(
x = TEMPO,
y = trait,
group = interaction(FEN, ab, especie, rep),
colour = FEN
)
) +
geom_line() +
labs(x = "Time",
y = "Mean phenotypes") +
scale_color_viridis(discrete=TRUE,
name = NULL
) +
theme_pubclean() + theme(
axis.text.x = element_text(
size = 15,
angle = 0,
vjust = 0.3
),
axis.text.y = element_text(size = 15),
plot.title = element_text(size = 15),
legend.text = element_text(size = 15),
axis.title.x = element_text(size = 15),
axis.title.y = element_text(size = 15),
strip.text.x = element_text(size = 15),
strip.text.y = element_text(size = 15),
plot.caption = element_text(size=15),
panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(colour = "black"),
axis.ticks = element_blank(),
legend.position = "top"
) +
facet_grid_paginate(
beta ~ alpha+rep,
ncol = 5,
nrow = 6,
page = i, labeller = label_bquote(beta == .(beta), alpha == .(alpha)))))
}
How can I achieve that?
thanks in advance! and sorry about my english :)

Related

Group by several columns and print

I have a data frame where I want at the end to print the results of several columns grouped by the number of observations of each column and their frequency separately.
This is what I have done, but it gives me the count and freq of the total but I want for each column, q1a, q1a_30d,q1a_60d,q1a_90d
a<- df %>% group_by(q1a, q1a_30d, q1a_60d,q1a_90d) %>% summarise(cnt = n()) %>%mutate(freq = formattable::percent(cnt / sum(cnt),1))
and then for print
kable( a, col.names = c(" ", "cnt", "freq"),align = c("lcr"),longtable = T, booktabs = T, valign = 't', escape = F, caption = '<b> Wore a face covering or mask<b>') %>%
kable_styling(bootstrap_options = c("striped", "hold_position"),full_width = T,position = "center",html_font = "Arial") %>%
add_header_above(c("Baseline", "30 days", "60 days", "90 days"))%>%
column_spec(border_left = T, border_right = T)
dput(a[1:10, ])
structure(list(q1a = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,1L, 1L, 1L), .Label = c("All of the time", "Very frequently", "Somewhat frequently", "Never", "No answer"), class = "factor"), q1a_30d = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,2L), .Label = c("All of the time", "Very frequently", "Somewhat frequently", "Never", "No answer"), class = "factor"), q1a_60d = structure(c(1L, 1L, 1L, 1L, 2L, 3L, 5L, 1L, 2L, 2L), .Label = c("All of the time", "Very frequently", "Somewhat frequently", "Never", "No answer"), class = "factor"), q1a_90d = structure(c(1L, 2L, 3L, 5L,5L, 1L, 5L, 1L, 1L, 3L), .Label = c("All of the time", "Very frequently", "Somewhat frequently", "Never", "No answer"), class = "factor"), cnt = c(8L, 1L, 1L, 13L, 1L, 1L, 14L, 4L, 1L, 1L), freq = structure(c(0.347826086956522, 0.0434782608695652, 0.0434782608695652, 0.565217391304348, 1, 1, 1, 1, 0.5, 0.5), formattable = list(formatter = "formatC", format = list(format = "f", digits = 1), preproc = "percent_preproc", postproc = "percent_postproc"), class = c("formattable", "numeric"))), row.names = c(NA, -10L), groups = structure(list(q1a = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("All of the time", "Very frequently", "Somewhat frequently", "Never", "No answer"), class = "factor"), q1a_30d = structure(c(1L, 1L, 1L, 1L,2L, 2L), .Label = c("All of the time", "Very frequently","Somewhat frequently", "Never", "No answer"), class = "factor"),q1a_60d = structure(c(1L, 2L, 3L, 5L, 1L, 2L), .Label = c("All of the time","Very frequently", "Somewhat frequently", "Never", "No answer"), class = "factor"), .rows = structure(list(1:4, 5L, 6L,7L, 8L, 9:10), ptype = integer(0), class = ("vctrs_list_of","vctrs_vctr", "list"))), row.names = c(NA, -6L), class = c("tbl_df","tbl", "data.frame"), .drop = TRUE), class = c("grouped_df", "tbl_df", "tbl", "data.frame"))

Splitting a facet wrap into two additional facets

I am using the following to plot some data, however on the full sample the data is a little difficult to see since I have too many variables on the same plot. How can I split each of the facets into 2? That is, have the first half of the variables plotted on one line and the second half of the variables plotted on the second line but keep each of the current 4 facets?.
ggplot code removed due to character limit
Data:
structure(list(Status = structure(c(2L, 1L, 1L, 2L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L,
2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L,
1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 1L, 1L, 1L, 1L, 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1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L), .Label = c("0",
"1"), class = "factor"), Model = c("2", "3", "2", "2", "2", "4",
"2", "3", "3", "2", "1", "4", "3", "1", "4", "3", "3", "3", "2",
"1", "2", "1", "2", "3", "3", "3", "3", "4", "3", "2", "1", "3",
"1", "2", "1", "1", "4", "2", "2", "4", "4", "2", "2", "1", "4",
"1", "2", "2", "3", "2", "4", "3", "3", "3", "2", "3", "2", "3",
"4", "1", "2", "3", "2", "2", "3", "4", "2", "3", "1", "1", "3",
"4", "4", "4", "2", "1", "2", "3", "4", "3", "2", "4", "1", "1",
"1", "2", "2", "2", "4", "3", "1", "4", "3", "2", "2", "4", "1",
"4", "1", "1", "3", "4", "2", "3", "3", "3", "4", "3", "3", "3",
"2", "4", "1", "2", "4", "1", "4", "3", "2", "2", "4", "2", "4",
"4", "4", "4", "4", "1", "4", "1", "1", "2", "3", "3", "4", "1",
"4", "3", "3", "1", "3", "1", "1", "3", "1", "4", "3", "1", "4",
"4", "2", "2", "4", "1", "1", "2", "2", "4", "1", "1", "2", "2",
"3", "3", "2", "1", "3", "3", "4", "3", "1", "4", "2", "4", "3",
"4", "4", "3", "2", "2", "3", "1", "1", "1", "4", "3", "4", "3",
"2", "1", "3", "1", "4", "3", "4", "3", "2", "3", "3", "3", "3",
"1", "4", "1", "1", "3", "3", "4", "1", "1", "3", "4", "2", "1",
"4", "4", "1", "4", "4", "2", "1", "3", "2", "1", "3", "2", "2",
"1", "1", "4", "1", "4", "2", "2", "4", "1", "3", "3", "2", "4",
"3", "1", "2", "3", "1", "4", "3", "1", "2", "4", "2", "3", "1",
"4", "1", "3", "1", "4", "1", "4", "1", "3", "4", "1", "2", "3",
"4", "3", "2", "4", "3", "2", "2", "1", "2", "2", "1", "4", "2",
"4", "3", "2", "1", "1", "3", "3", "3", "4", "4", "4", "3", "4",
"4", "2", "1", "4", "1", "3", "1", "2", "1", "4", "3", "1", "3",
"4", "1", "1", "4", "4", "1", "3", "4", "1", "1", "1", "1", "4",
"4", "2", "4", "3", "1", "4", "1", "2", "4", "1", "4", "2", "2",
"3", "4", "2", "4", "4", "4", "3", "4", "4", "1", "3", "3", "2",
"4", "4", "1", "1", "2", "2", "2", "3", "3", "4", "3", "2", "4",
"4", "4", "1", "2", "4", "4", "4", "3", "2", "2", "3", "4", "1",
"3", "1", "4", "1", "3", "2", "3", "3", "3", "4", "3", "1", "4",
"4", "4", "1", "3", "3", "1", "1", "1", "3", "2", "4", "4", "3",
"3", "3", "2", "2", "1", "3", "1", "4", "1", "4", "3", "1", "2",
"3", "3", "1", "2", "4", "4", "2", "2", "4", "3", "1", "1", "4",
"2", "4", "2", "2", "1", "3", "4", "3", "4", "3", "2", "3", "2",
"4", "2", "1", "1", "4", "3", "3", "4", "4", "4", "4", "1", "1",
"2", "4", "4", "2", "3", "3", "2", "2", "3", "4", "4", "1", "2",
"1", "1", "2", "2", "1", "2", "3", "3", "4", "1", "3", "4", "1",
"4", "1", "2", "3", "2", "3", "2", "4", "2", "1", "4", "3", "1",
"2", "3", "3", "2", "2", "4", "4", "1", "4", "4", "3", "1", "3"
), Model_Name = c("2 Year", "3 Year", "2 Year", "2 Year", "2 Year",
"4 Year", "2 Year", "3 Year", "3 Year", "2 Year", "1 Year", "4 Year",
"3 Year", "1 Year", "4 Year", "3 Year", "3 Year", "3 Year", "2 Year",
"1 Year", "2 Year", "1 Year", "2 Year", "3 Year", "3 Year", "3 Year",
"3 Year", "4 Year", "3 Year", "2 Year", "1 Year", "3 Year", "1 Year",
"2 Year", "1 Year", "1 Year", "4 Year", "2 Year", "2 Year", "4 Year",
"4 Year", "2 Year", "2 Year", "1 Year", "4 Year", "1 Year", "2 Year",
"2 Year", "3 Year", "2 Year", "4 Year", "3 Year", "3 Year", "3 Year",
"2 Year", "3 Year", "2 Year", "3 Year", "4 Year", "1 Year", "2 Year",
"3 Year", "2 Year", "2 Year", "3 Year", "4 Year", "2 Year", "3 Year",
"1 Year", "1 Year", "3 Year", "4 Year", "4 Year", "4 Year", "2 Year",
"1 Year", "2 Year", "3 Year", "4 Year", "3 Year", "2 Year", "4 Year",
"1 Year", "1 Year", "1 Year", "2 Year", "2 Year", "2 Year", "4 Year",
"3 Year", "1 Year", "4 Year", "3 Year", "2 Year", "2 Year", "4 Year",
"1 Year", "4 Year", "1 Year", "1 Year", "3 Year", "4 Year", "2 Year",
"3 Year", "3 Year", "3 Year", "4 Year", "3 Year", "3 Year", "3 Year",
"2 Year", "4 Year", "1 Year", "2 Year", "4 Year", "1 Year", "4 Year",
"3 Year", "2 Year", "2 Year", "4 Year", "2 Year", "4 Year", "4 Year",
"4 Year", "4 Year", "4 Year", "1 Year", "4 Year", "1 Year", "1 Year",
"2 Year", "3 Year", "3 Year", "4 Year", "1 Year", "4 Year", "3 Year",
"3 Year", "1 Year", "3 Year", "1 Year", "1 Year", "3 Year", "1 Year",
"4 Year", "3 Year", "1 Year", "4 Year", "4 Year", "2 Year", "2 Year",
"4 Year", "1 Year", "1 Year", "2 Year", "2 Year", "4 Year", "1 Year",
"1 Year", "2 Year", "2 Year", "3 Year", "3 Year", "2 Year", "1 Year",
"3 Year", "3 Year", "4 Year", "3 Year", "1 Year", "4 Year", "2 Year",
"4 Year", "3 Year", "4 Year", "4 Year", "3 Year", "2 Year", "2 Year",
"3 Year", "1 Year", "1 Year", "1 Year", "4 Year", "3 Year", "4 Year",
"3 Year", "2 Year", "1 Year", "3 Year", "1 Year", "4 Year", "3 Year",
"4 Year", "3 Year", "2 Year", "3 Year", "3 Year", "3 Year", "3 Year",
"1 Year", "4 Year", "1 Year", "1 Year", "3 Year", "3 Year", "4 Year",
"1 Year", "1 Year", "3 Year", "4 Year", "2 Year", "1 Year", "4 Year",
"4 Year", "1 Year", "4 Year", "4 Year", "2 Year", "1 Year", "3 Year",
"2 Year", "1 Year", "3 Year", "2 Year", "2 Year", "1 Year", "1 Year",
"4 Year", "1 Year", "4 Year", "2 Year", "2 Year", "4 Year", "1 Year",
"3 Year", "3 Year", "2 Year", "4 Year", "3 Year", "1 Year", "2 Year",
"3 Year", "1 Year", "4 Year", "3 Year", "1 Year", "2 Year", "4 Year",
"2 Year", "3 Year", "1 Year", "4 Year", "1 Year", "3 Year", "1 Year",
"4 Year", "1 Year", "4 Year", "1 Year", "3 Year", "4 Year", "1 Year",
"2 Year", "3 Year", "4 Year", "3 Year", "2 Year", "4 Year", "3 Year",
"2 Year", "2 Year", "1 Year", "2 Year", "2 Year", "1 Year", "4 Year",
"2 Year", "4 Year", "3 Year", "2 Year", "1 Year", "1 Year", "3 Year",
"3 Year", "3 Year", "4 Year", "4 Year", "4 Year", "3 Year", "4 Year",
"4 Year", "2 Year", "1 Year", "4 Year", "1 Year", "3 Year", "1 Year",
"2 Year", "1 Year", "4 Year", "3 Year", "1 Year", "3 Year", "4 Year",
"1 Year", "1 Year", "4 Year", "4 Year", "1 Year", "3 Year", "4 Year",
"1 Year", "1 Year", "1 Year", "1 Year", "4 Year", "4 Year", "2 Year",
"4 Year", "3 Year", "1 Year", "4 Year", "1 Year", "2 Year", "4 Year",
"1 Year", "4 Year", "2 Year", "2 Year", "3 Year", "4 Year", "2 Year",
"4 Year", "4 Year", "4 Year", "3 Year", "4 Year", "4 Year", "1 Year",
"3 Year", "3 Year", "2 Year", "4 Year", "4 Year", "1 Year", "1 Year",
"2 Year", "2 Year", "2 Year", "3 Year", "3 Year", "4 Year", "3 Year",
"2 Year", "4 Year", "4 Year", "4 Year", "1 Year", "2 Year", "4 Year",
"4 Year", "4 Year", "3 Year", "2 Year", "2 Year", "3 Year", "4 Year",
"1 Year", "3 Year", "1 Year", "4 Year", "1 Year", "3 Year", "2 Year",
"3 Year", "3 Year", "3 Year", "4 Year", "3 Year", "1 Year", "4 Year",
"4 Year", "4 Year", "1 Year", "3 Year", "3 Year", "1 Year", "1 Year",
"1 Year", "3 Year", "2 Year", "4 Year", "4 Year", "3 Year", "3 Year",
"3 Year", "2 Year", "2 Year", "1 Year", "3 Year", "1 Year", "4 Year",
"1 Year", "4 Year", "3 Year", "1 Year", "2 Year", "3 Year", "3 Year",
"1 Year", "2 Year", "4 Year", "4 Year", "2 Year", "2 Year", "4 Year",
"3 Year", "1 Year", "1 Year", "4 Year", "2 Year", "4 Year", "2 Year",
"2 Year", "1 Year", "3 Year", "4 Year", "3 Year", "4 Year", "3 Year",
"2 Year", "3 Year", "2 Year", "4 Year", "2 Year", "1 Year", "1 Year",
"4 Year", "3 Year", "3 Year", "4 Year", "4 Year", "4 Year", "4 Year",
"1 Year", "1 Year", "2 Year", "4 Year", "4 Year", "2 Year", "3 Year",
"3 Year", "2 Year", "2 Year", "3 Year", "4 Year", "4 Year", "1 Year",
"2 Year", "1 Year", "1 Year", "2 Year", "2 Year", "1 Year", "2 Year",
"3 Year", "3 Year", "4 Year", "1 Year", "3 Year", "4 Year", "1 Year",
"4 Year", "1 Year", "2 Year", "3 Year", "2 Year", "3 Year", "2 Year",
"4 Year", "2 Year", "1 Year", "4 Year", "3 Year", "1 Year", "2 Year",
"3 Year", "3 Year", "2 Year", "2 Year", "4 Year", "4 Year", "1 Year",
"4 Year", "4 Year", "3 Year", "1 Year", "3 Year"), status = c(1L,
0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L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ES", "CF.SALES", "EBIT.FinExp",
"EQ.Turnover", "WC.EBIT", "logTA", "CA.CL", "CF.SALES", "CF.NCL",
"EBIT.FinExp", "EQ.Turnover", "SALES.FA", "SALES.FA", "EBITDA.SALES",
"EBITDA.SALES", "CL.FinExp", "logTA", "CF.CL", "SALES.EBIT",
"DEBTORS.SALES", "WC.EBIT", "CF.NCL", "SALES.FA", "CF.NCL", "CA.CL",
"logSALES", "EBITDA.SALES", "TL.TA", "EBIT.FinExp", "EQ.Turnover",
"CF.SALES", "TL.EQ", "EQ.Turnover", "SALES.EBIT", "logTA", "EBIT.FinExp",
"logSALES", "EBIT.Capital", "EBIT.FinExp", "CF.CL", "SALES.EBIT",
"CF.NCL", "EBIT.FinExp", "SALES.FA", "TL.EQ", "EBITDA.SALES",
"logSALES", "WC.EBIT", "TL.TA", "TL.EQ", "EBIT.Capital", "logTA",
"logTA", "EBIT.Capital", "logSALES", "WC.EBIT", "logSALES", "TL.TA",
"EQ.Turnover", "CF.SALES", "logSALES", "EBIT.FinExp", "EBITDA.SALES",
"TL.EQ", "EBIT.Capital", "DEBTORS.SALES", "TL.TA", "EBIT.FinExp",
"SALES.FA", "DEBTORS.SALES", "CL.FinExp", "logTA", "EBIT.Capital",
"CF.NCL", "DEBTORS.SALES", "CF.SALES", "EBIT.Capital", "CA.CL",
"CF.NCL", "CF.SALES", "EBITDA.SALES", "EBIT.FinExp", "EBIT.Capital",
"DEBTORS.SALES", "EQ.Turnover", "TL.EQ", "TL.EQ", "CL.FinExp",
"EQ.Turnover", "logTA", "CF.SALES", "DEBTORS.SALES", "CF.CL",
"TL.TA", "CL.FinExp", "logTA", "CL.FinExp", "SALES.FA", "SALES.EBIT",
"SALES.EBIT", "EBITDA.SALES", "EBITDA.SALES", "WC.EBIT", "DEBTORS.SALES",
"DEBTORS.SALES", "DEBTORS.SALES", "EQ.Turnover", "WC.EBIT", "CL.FinExp",
"EQ.Turnover", "TL.TA", "CA.CL", "logSALES", "SALES.FA", "logTA",
"CL.FinExp", "CF.SALES", "logSALES", "EBITDA.SALES", "TL.TA",
"SALES.EBIT", "EBIT.FinExp", "EBIT.Capital", "CL.FinExp", "EQ.Turnover",
"SALES.FA", "logSALES", "CF.CL", "logTA", "CF.CL", "SALES.FA",
"logTA", "SALES.EBIT", "CL.FinExp", "WC.EBIT", "TL.EQ", "CL.FinExp",
"CL.FinExp", "EBITDA.SALES", "SALES.EBIT", "CF.CL", "DEBTORS.SALES",
"logTA", "logSALES", "TL.TA", "EQ.Turnover", "EQ.Turnover", "CL.FinExp",
"TL.TA", "EBIT.FinExp", "EBIT.Capital", "CF.SALES", "EBIT.FinExp",
"DEBTORS.SALES", "CL.FinExp", "CL.FinExp", "logSALES", "CA.CL",
"CF.CL", "SALES.FA", "DEBTORS.SALES", "CF.SALES", "CA.CL", "CL.FinExp",
"logTA", "SALES.FA", "DEBTORS.SALES", "SALES.FA", "EBITDA.SALES",
"EQ.Turnover", "EQ.Turnover", "logSALES", "EBIT.Capital", "CF.NCL",
"CA.CL", "logTA", "CF.SALES", "CF.CL", "DEBTORS.SALES", "SALES.EBIT",
"SALES.EBIT", "TL.EQ", "TL.EQ", "SALES.EBIT", "EBIT.FinExp",
"CF.SALES", "SALES.FA", "CL.FinExp", "WC.EBIT", "CF.NCL", "CL.FinExp",
"CF.CL", "logTA", "CF.SALES", "CA.CL", "logTA", "CF.CL", "EBIT.FinExp",
"CA.CL", "TL.EQ", "CF.CL", "logSALES", "TL.EQ", "EQ.Turnover",
"CL.FinExp", "SALES.FA", "EBIT.FinExp", "EBIT.Capital", "EQ.Turnover",
"CF.NCL", "CF.CL", "DEBTORS.SALES", "CL.FinExp", "TL.EQ", "CF.SALES",
"DEBTORS.SALES", "CL.FinExp", "CL.FinExp", "WC.EBIT", "EBIT.Capital",
"EBIT.Capital", "CA.CL", "EBITDA.SALES", "WC.EBIT", "EQ.Turnover",
"DEBTORS.SALES", "CL.FinExp", "CA.CL", "CF.NCL", "logSALES",
"DEBTORS.SALES", "WC.EBIT", "logSALES", "DEBTORS.SALES", "EBIT.Capital",
"DEBTORS.SALES", "CL.FinExp", "logSALES", "CA.CL", "WC.EBIT",
"CF.SALES", "TL.TA", "SALES.EBIT", "EBIT.FinExp", "SALES.FA",
"EBIT.FinExp", "WC.EBIT", "logTA", "DEBTORS.SALES", "TL.TA",
"CF.SALES", "EBIT.FinExp", "logSALES", "CF.SALES", "EBITDA.SALES",
"SALES.FA", "logSALES", "logSALES", "CF.CL", "CF.SALES", "CF.SALES",
"EBIT.Capital", "TL.TA", "EBIT.Capital", "CF.SALES", "SALES.FA",
"CF.CL", "TL.TA", "CL.FinExp", "TL.EQ", "CF.SALES", "CL.FinExp",
"logSALES", "DEBTORS.SALES", "CF.CL", "TL.EQ", "CA.CL", "DEBTORS.SALES",
"CA.CL", "SALES.FA", "SALES.EBIT", "SALES.FA", "logSALES", "TL.TA",
"logTA", "CA.CL", "CL.FinExp", "TL.TA", "CF.CL", "TL.EQ", "CF.NCL",
"WC.EBIT", "SALES.FA", "SALES.FA", "DEBTORS.SALES", "EBIT.Capital",
"EBITDA.SALES", "SALES.EBIT", "logSALES", "CF.NCL", "WC.EBIT",
"CL.FinExp", "EBIT.Capital", "CF.CL", "WC.EBIT", "SALES.FA",
"EBIT.FinExp", "CF.NCL", "WC.EBIT", "EBIT.FinExp", "SALES.FA",
"CF.SALES", "CF.NCL", "SALES.FA", "CL.FinExp", "CF.NCL", "TL.EQ",
"CA.CL", "logTA", "CL.FinExp", "DEBTORS.SALES", "CF.SALES", "CF.CL",
"TL.TA", "SALES.EBIT", "EQ.Turnover", "CA.CL", "SALES.FA", "CF.CL",
"EQ.Turnover", "CF.CL", "EBIT.Capital", "CL.FinExp", "CA.CL",
"DEBTORS.SALES", "EQ.Turnover", "CF.SALES", "CF.SALES", "TL.EQ",
"EBIT.Capital", "CF.SALES", "TL.TA", "WC.EBIT", "EQ.Turnover",
"WC.EBIT", "EBIT.Capital", "WC.EBIT", "logTA", "CF.SALES", "logTA",
"WC.EBIT", "CF.NCL", "SALES.FA", "WC.EBIT", "WC.EBIT", "EBIT.Capital",
"EQ.Turnover", "logTA", "SALES.EBIT", "TL.TA", "CF.NCL", "EBITDA.SALES",
"logSALES", "CL.FinExp", "SALES.EBIT", "TL.EQ", "DEBTORS.SALES",
"TL.EQ", "EQ.Turnover", "EBIT.Capital", "TL.EQ", "EBIT.FinExp",
"EBIT.FinExp", "CA.CL", "CL.FinExp", "TL.TA", "EBIT.Capital",
"logTA", "CL.FinExp", "CF.NCL", "CA.CL", "CL.FinExp", "EBITDA.SALES",
"CA.CL", "EQ.Turnover", "CL.FinExp", "SALES.EBIT", "CA.CL", "SALES.FA",
"TL.EQ", "EQ.Turnover", "EQ.Turnover", "EBITDA.SALES", "SALES.FA",
"logSALES", "SALES.EBIT", "EQ.Turnover", "WC.EBIT", "SALES.FA",
"EBIT.FinExp", "TL.TA", "DEBTORS.SALES", "SALES.EBIT", "WC.EBIT",
"logSALES", "EBIT.Capital", "WC.EBIT", "EQ.Turnover", "EBITDA.SALES",
"TL.EQ", "CF.CL", "EBIT.Capital", "CF.CL", "TL.EQ", "CF.NCL",
"WC.EBIT", "WC.EBIT", "EBITDA.SALES", "SALES.EBIT", "CF.NCL",
"CF.NCL", "CA.CL", "logSALES", "EBITDA.SALES", "EBIT.FinExp",
"SALES.EBIT", "TL.EQ", "CF.CL", "EBIT.Capital", "logTA", "EBITDA.SALES",
"EBIT.Capital", "TL.TA", "DEBTORS.SALES", "WC.EBIT", "DEBTORS.SALES",
"CF.SALES", "logTA", "SALES.EBIT", "EQ.Turnover", "CA.CL", "WC.EBIT",
"EBITDA.SALES", "EBITDA.SALES", "DEBTORS.SALES", "CA.CL", "EBIT.FinExp",
"EQ.Turnover", "DEBTORS.SALES", "CA.CL", "CF.NCL", "DEBTORS.SALES",
"logSALES", "CA.CL", "SALES.EBIT", "EBIT.Capital", "CA.CL", "DEBTORS.SALES",
"EBIT.FinExp", "logTA", "EBITDA.SALES", "DEBTORS.SALES", "EBITDA.SALES",
"CF.CL", "CA.CL", "CF.NCL", "CA.CL", "CA.CL", "SALES.EBIT", "CA.CL",
"DEBTORS.SALES", "TL.TA", "CF.SALES", "CA.CL", "SALES.FA", "EBIT.FinExp",
"SALES.EBIT", "CF.SALES", "CA.CL", "CF.NCL", "EBIT.Capital",
"DEBTORS.SALES", "EQ.Turnover", "TL.EQ", "EBITDA.SALES", "WC.EBIT",
"SALES.FA", "DEBTORS.SALES"), Ratio = c(-0.707919201865374, 0.534298237128927,
0.763308535784903, -1.24540281291686, 0.332626927584044, -0.485527331169614,
-0.626125641168283, 1.75345016963661, 4.51002074747425, NA, NA,
NA, NA, NA, 0.812093120581957, 0.261889212102065, 0.330583042088873,
1.86055950229721, -0.559740348093955, -0.751550592131927, -0.583664251852244,
-0.522445867895311, -0.686761191590487, -0.582852934868012, -0.388631437021738,
-0.376042040118803, 1.42792549342901, -0.498990070660728, 0.208683983665681,
2.14576274581865, -0.768210439875085, 0.53597295004055, -0.653782593991037,
-0.401467349422482, 0.955113642471936, 1.53488585290567, -0.3952130632778,
NA, 0.144744549336861, -1.11766418734528, NA, -0.486293007398917,
-0.337866870638434, -0.665794733109122, 0.526585766173069, -0.330968739102218,
-1.71872921769721, NA, -0.603494884009451, -0.669873024581416,
NA, -0.649826514192686, 3.07036655149694, NA, 2.13760005383415,
0.48611918602065, -0.46490903620693, 1.76231954464496, -0.904090534873578,
-0.597689611958551, 0.570443208862788, -0.295696356825069, NA,
NA, -1.12026151337091, 0.353252456885539, -0.410737653008626,
-0.492832999764316, -0.964106737223811, 0.771902521119517, -0.690879784763869,
NA, 0.20812644470003, NA, -0.702318717339072, -0.725246730786497,
-0.611066135478997, -0.752358284437105, NA, -0.336177411573904,
NA, -0.972007939780494, NA, 0.588136079183467, -0.189762086807928,
NA, -0.090507528727365, NA, -0.0414476119071152, -0.591736889328259,
-0.5129649441072, 3.38321349285669, -0.83540453095325, NA, -0.464060181907834,
0.170933923104933, -0.48321974573862, -0.724726093759333, 2.13475323186374,
-0.551720107396813, -0.626677016637103, NA, NA, NA, 0.652318574413187,
-1.02928500954333, -0.554231821404908, NA, 0.367065924508534,
4.01819284884926, 0.845766884268474, -0.70159006627801, -0.280390290506344,
-0.626223193308945, -0.4690747657034, NA, NA, -0.890480886392398,
-0.478386122102566, -0.0161475286907884, 0.253289117743233, -0.547105578584289,
0.380874662395742, -0.818329487977687, NA, NA, 0.955752645159877,
NA, NA, -0.994832250856227, -0.449101510108994, 0.0694474558888659,
-0.598563168472843, -0.486097896726921, NA, -0.371989877402075,
NA, -0.318581703636123, NA, -0.100445919052522, 0.799824845462438,
0.378210972442923, 1.27868945760894, 0.24318089910497, 0.181578779346068,
NA, -0.685683467561987, -0.459631884960373, 1.63095980160168,
NA, 0.0946018130113362, 1.02705324936134, 0.671527084464841,
NA, -0.7233085189248, -0.12675734621849, -1.38656705544647, -0.560915914512089,
-0.651921766209563, -0.27953897460903, 0.291991314562734, -0.528392572004289,
NA, NA, 1.50012078788565, NA, NA, NA, 1.31640767511872, -0.445442274834121,
-0.414856728587356, -0.314051160102572, 0.375744307410188, NA,
1.81781116610221, -0.559946887602694, -0.395457514182639, NA,
-0.00526745113271141, -0.332325214798845, -0.018280127030989,
1.62199240527132, -0.594479361680451, -0.564198930580082, NA,
-0.62167492692037, -0.416303523892455, -0.449607506297853, 0.903845712282351,
0.779684646559823, 0.143738281941008, -0.499873895126271, -0.641177881704429,
NA, NA, -0.273314809518737, -0.529847731746218, NA, -0.173764991270002,
-0.354344496593425, NA, 0.478253576057706, NA, -0.187311787706413,
0.123066579596889, -0.513750460779892, NA, -0.790302221045379,
0.804382183064051, NA, -0.297655481061757, -0.629830122961466,
NA, -0.519316349381646, NA, -0.704915022051129, -0.577424583637617,
NA, -0.482010018569492, 0.238837508589818, -0.532068808898047,
0.297453160922741, -0.755306596376328, 0.578212039243233, -0.450857004957819,
-0.748403848598439, -0.37679058952789, 0.0241775484739816, 0.192730082758945,
-0.515145439910768, -0.2268625780629, 3.01576448103222, -0.583866152304867,
-0.709552047052377, 0.425623875604783, -0.176544051505707, -0.620792120166673,
-0.955353796034912, NA, -0.809318960526967, 0.420023768667055,
-0.10523384165629, 0.406993073561131, -0.651798854673955, 0.716344972440134,
-0.303352449044368, -0.668984877006987, NA, -0.564780013255765,
-1.05118700631593, -0.539116726883504, -0.450800652766572, -0.749871688838548,
-0.0841302606072373, -0.709221367461288, -0.490910197160739,
1.11027172778273, NA, -0.601870914727605, -0.552107614649751,
1.62516615465747, 2.44418728489504, -0.409209593330642, NA, -0.960828529382557,
0.084165536089424, -0.705514388724782, -0.610463822925471, 0.497068681435134,
-0.901651796426343, -0.435677866991515, 0.233314727709829, NA,
0.00852960753143773, NA, -0.115106662664484, -0.770897489615408,
-0.0354281980844262, -0.407056468073408, NA, -0.485108803557962,
1.08794794256967, -0.190125931876589, -0.402265379206689, 1.1424132722547,
0.135126477946112, -0.603939243675491, -0.717615437622428, -1.00910526031101,
2.22705685835911, NA, NA, NA, 2.64407175315141, -0.0446459000716095,
0.415476261684389, 0.796821253852406, 0.201011466923258, -0.544530194375183,
-1.22140141358447, -0.360101158862896, 3.45535955026293, NA,
-0.448286766138525, 0.811084846975265, -0.527021372402286, 1.3424732936182,
3.61314912518142, -0.463269606554065, 0.0405953936802976, -0.146586169376855,
NA, 2.12231677541413, NA, -0.636743440094211, -0.615559966343366,
-0.571577080857255, 2.50953454213711, -0.300544588599613, -0.0362964175170153,
-0.619520327701307, -0.502959017927762, -0.372855255378387, 1.31539147808008,
-0.394080181754502, NA, -0.00352084504014205, -0.55495656291638,
0.480334834629862, 1.63500140088775, -1.15012988133644, -0.569867634951047,
0.360801001739192, -0.679469512958559, NA, 0.580475615397198,
NA, 2.25455662583243, -0.759165766527588, -0.451095627447786,
-0.15783276233868, -0.172816536529721, -0.217054425468797, -0.184291097560009,
NA, 0.546420739451911, NA, -0.490529780725351, -0.333472258672436,
-0.438198173702863, -0.646280348380046, -0.630225889980435, -0.705124582982999,
-1.77969797337541, -0.402601268399203, -0.222140988823231, 0.576239927127392,
NA, -0.321675775893816, -0.251829942792891, 1.02695194871569,
0.61619363855965, -0.423739089065777, 0.764954823524791, -0.576377283963124,
0.0839707252843906, -0.466579922080166, -0.484544994892477, -0.397657628622839,
-1.05472151674597, 3.2212462997121, -0.0231910345270541, -0.167537885665263,
-0.492795538660388, 1.97581659699565, -0.499098597312652, 0.56861641397915,
-0.676879586334823, -0.125334637509097, 1.29393839101515, -0.636084619567668,
0.282217561163258, -0.406032294129199, 1.11832771373931, -0.357200115739465,
3.47191854245104, NA, NA, -0.323001011945709, 0.829062755141093,
NA, -0.471688857638298, -0.944225375006027, -0.341659690874536,
-0.420054310804183, -0.455765315492974, NA, NA, -0.362113287165822,
0.77088554356236, 0.315220067697118, -0.0794308626912546, 1.46915410747046,
-0.522548665811739, 0.230255494859231, -0.560629395458324, 0.470723132557846,
-0.761260095149801, -0.476098269898868, NA, -0.669458501886402,
-0.532247910499081, 1.06219015600794, NA, -0.714135539638932,
-0.658027312807696, -0.433435994975457, -0.511392591593316, -0.230059145876329,
NA, 0.0111443539074219, -0.684454010718469, -0.625946669480515,
NA, -0.46617948856222, -0.744977753108209, -0.445294244818825,
-0.702413841896356, -0.714672830111507, NA, NA, NA, 0.85804073380322,
NA, -1.25848825367149, NA, NA, 0.446328793506625, -0.752068298980925,
0.122145113318285, 0.849904783555482, NA, -0.78129893263372,
-0.537436099444471, 0.198639023895424, -0.990836594347679, -0.654663516018546,
1.08110583478396, 1.0640799538555, 0.537681922023906, -0.309706876113679,
-0.439635273472738, NA, -0.368011612232917, NA, 3.50174925043846,
-0.39927048724593, -0.926281959133432, -0.376881673897987, -0.162880850919552,
-0.142649303086233, 1.09678336275476, NA, -0.879837401893792,
-0.414955051475592, -0.920399731144902, -0.699788115735192, 2.57172151516347,
0.267771491217914, 0.171724262110164, NA, 3.06797562926558, -0.241808057899617,
-0.685811369433853, NA, 1.85597513761496, NA, -0.521621841883141,
-0.305316470900169, NA, -0.539698980199801, -0.0720400072423283,
NA, 0.437389975954819, 4.10831662855063, 4.42138430051713, NA,
-0.494316690230473, -0.792706118884541, 2.73285642246282, -0.192689903505749,
-0.492415961149561, NA, -0.974988170595545, -0.21084424861102,
-0.751334790010609, -0.00141664743077581, -0.674592842718741,
0.138632188019161, NA)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -500L))
EDIT: ggplot theme:
library(tidyquant) # for theme_tq()
theme(strip.text=element_blank(),
#aspect.ratio = 1,
axis.line.y = element_blank(),
axis.ticks.y = element_blank(),
legend.position = "bottom",
legend.title = element_text(size = 20),
legend.text = element_text(size = 10),
axis.title = element_text(size = 20),
axis.text = element_text(size = "15"),
strip.text.x = element_text(size = 15),
plot.title = element_text(size = 30),
strip.background = element_rect(fill = 'darkred'),
panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.text.x = element_text(angle = 90),
axis.title.x=element_blank()) +
labs(title=.x[["Model_Name"]][1]) +
theme_tq(base_family = "serif")
We can create a new grouping variable that places the Feature values into one of two groups and then use that grouping variable for faceting.
We then split the data by Model_Name into a list with four elements, one data frame for each level of Model_Name.
Using map, we feed this list of four data frames into ggplot to create a separate plot for each level of Model_Name. The code uses element_textbox_simple from the new ggtext package to add a colored background strip to the title of each plot in order to simulate facet labels (we removed the "real" facet labels because they are non-informative and also because we want the label to appear only once per pair of plots).
We then lay out the four plots using the patchwork package.
library(tidyverse)
library(patchwork)
# remotes::install_github("wilkelab/ggtext")
library(ggtext)
# Set general plot theme
theme_set(theme_classic() +
theme(panel.background=element_rect(colour="grey40", fill=NA)))
pd = position_dodge(width=0.9)
# Create a list of four ggplots, one for each level of Model_Name
pl = d %>%
# Create grouping variable to split Feature into two groups
mutate(group = ifelse(as.numeric(factor(Feature)) <= 0.5*length(unique(Feature)),
"g1","g2")) %>%
# Split data into a list of four data frames, one for each level of Model_Name
group_split(Model_Name) %>%
# Create a list of four plots
map(
~ ggplot(.x, aes(x = Feature, y = Ratio, fill = Status)) +
geom_violin(alpha = 0.5, scale = "width", position = pd) +
geom_boxplot(alpha = 1, width = 0.2, position = pd) +
scale_y_continuous(limits = c(-3, 4)) +
facet_wrap(~ group, ncol=1, scales="free_x") +
theme(strip.background=element_blank(),
strip.text=element_blank(),
axis.title.x=element_blank(),
plot.title=element_textbox_simple(fill="grey80",
halign=0.5, size=11,
padding=margin(t=4, b=2))) +
labs(title=.x[["Model_Name"]][1])
)
# Add single x-axis title to bottom plot
pl[[4]] = pl[[4]] +
theme(axis.title.x=element_text(margin=margin(t=5))) +
labs(x="Feature")
wrap_plots(pl, ncol=1) + plot_layout(guides="collect")

Issues spreading data after removing outliers

I put my data into long format, in order to remove outliers (I grouped by grade and condition, and then removed by 1.5 * IQR), however, I'm having issues getting it back into wide format. The final two columns (condition and variable (36, 37) are what I want to spread the data by (so that BOXED_Conjunction_12 becomes a variable). Variables 1:35 should remain as they are. (There will be NAs introduced given that outliers were removed; however, outliers were only removed per condition and not completely). I think I'm having issues because of removing the outliers, but I would think that fill = NA would solve this issue. Can't figure it out.
I've tried
dat%>%spread(condition,pid.avg_rw, fill = NA)
I've also tried using reshape2:
dat%>%dcast((1:35)~ condition, value.var = "pid.avg_rw")
and I get the error
number of rows of result is not a multiple of vector length (arg 1)Aggregation function missing: defaulting to length
Here's a dput of the first ten lines.
Thanks much,
James
structure(list(pid = c("ADMIN-UCSF-bo002", "ADMIN-UCSF-bo002",
"ADMIN-UCSF-bo002", "ADMIN-UCSF-bo002", "ADMIN-UCSF-bo002", "ADMIN-UCSF-bo002",
"ADMIN-UCSF-bo002", "ADMIN-UCSF-bo002", "ADMIN-UCSF-bo002", "ADMIN-UCSF-bo002"
), timepoint = c(1, 2, 3, 1, 2, 3, 1, 2, 3, 1), District.ID = c(175420L,
175420L, 175420L, 175420L, 175420L, 175420L, 175420L, 175420L,
175420L, 175420L), School = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L), .Label = c("Bowers", "Bracher", "Cabrillo",
"Central Park", "Laurelwood", "Millikin", "Peterson"), class = "factor"),
Ethnicity = structure(c(6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L), .Label = c("American Indian or Alaskan Native", "Asian",
"Black or African American", "Blank on Purpose", "Filipino",
"Hispanic or Latino", "Pacific Islander", "Two or More Races",
"White"), class = "factor"), Age.2018 = c(10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L), Sex = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("F", "M"), class = "factor"),
Language.Fluency = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), .Label = c("English Learner", "English Only",
"IFEP-Initially Fluent", "RFEP-Redesignated"), class = "factor"),
Parent.Ed.Lvl = structure(c(5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L), .Label = c("College Graduate", "Declined to state/Unknown",
"Grad School/post grad trng", "High School Graduate", "Not HS Graduate",
"Some College"), class = "factor"), SpEd = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("No", "Yes"
), class = "factor"), SpEd.Dis = structure(c(1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("", "Autism (AUT)",
"Emotional Disturbance (ED)", "Hard of Hearing (HH)", "Intellectual Disability (ID)",
"Other Health Impairment (OHI)", "Specific Learning Disability (SLD)",
"Speech or Language Impairment (SLI)", "Visual Impairment (VI)"
), class = "factor"), Low.Income = structure(c(2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("No", "Yes"), class = "factor"),
grade = c("3", "3", "4", "3", "3", "4", "3", "3", "4", "3"
), gender = c("F", "F", "2", "F", "F", "2", "F", "F", "2",
"F"), Teacher = c("Keith, Susan", "Keith, Susan", "Lourdes Martin",
"Keith, Susan", "Keith, Susan", "Lourdes Martin", "Keith, Susan",
"Keith, Susan", "Lourdes Martin", "Keith, Susan"), time = structure(c(17113,
17263, 17417, 17113, 17263, 17417, 17113, 17263, 17417, 17113
), class = "Date"), ela.score = c(2424, 2424, NA, 2424, 2424,
NA, 2424, 2424, NA, 2424), School.Year = c("2017", "2017",
"2018", "2017", "2017", "2018", "2017", "2017", "2018", "2017"
), math.score = c(2440, 2440, NA, 2440, 2440, NA, 2440, 2440,
NA, 2440), basc = c(NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_
), cohort = c("3", "3", "3", "3", "3", "3", "3", "3", "3",
"3"), attendance = c(96.1, 96.1, 100, 96.1, 96.1, 100, 96.1,
96.1, 100, 96.1), tme4 = structure(c(NA, 17655, 17655, NA,
17655, 17655, NA, 17655, 17655, NA), class = "Date"), t4.minus = c(6.39692965521615,
5.97126183979046, 5.47227067367148, 6.39692965521615, 5.97126183979046,
5.47227067367148, 6.39692965521615, 5.97126183979046, 5.47227067367148,
6.39692965521615), median_grade = c(1536.4, 1536.4, 1372.4,
1192, 1192, 1054, 986.6, 986.6, 871.6, 958.4), mad_grade = c(377.17344,
377.17344, 278.13576, 167.5338, 167.5338, 161.89992, 139.66092,
139.66092, 116.23584, 143.21916), lowerq = c(1323.7, 1323.7,
1226.2, 1102.2, 1102.2, 960.6, 902.9, 902.9, 804, 873.5),
upperq = c(1964.8, 1964.8, 1655.6, 1329.3, 1329.3, 1181.6,
1091.9, 1091.9, 964.2, 1074.1), iqr = c(641.1, 641.1, 429.4,
227.1, 227.1, 221, 189, 189, 160.2, 200.6), grade.threshold.upper = c(3888.1,
3888.1, 2943.8, 2010.6, 2010.6, 1844.6, 1658.9, 1658.9, 1444.8,
1675.9), grade.threshold.lower = c(-599.6, -599.6, -61.9999999999995,
420.9, 420.9, 297.6, 335.9, 335.9, 323.4, 271.7), mad = c(377.17344,
377.17344, 278.13576, 167.5338, 167.5338, 161.89992, 139.66092,
139.66092, 116.23584, 143.21916), z_rw = c(0.350390238376874,
0.0417183791440274, 0.171148318277673, -0.108910138097997,
-0.497500239197831, -0.365723152941879, 0.512731829784946,
-0.588322005081869, -0.0970981769116109, -0.290844134905211
), condition = c("BOXED_Conjunction_12", "BOXED_Conjunction_12",
"BOXED_Conjunction_12", "BOXED_Conjunction_4", "BOXED_Conjunction_4",
"BOXED_Conjunction_4", "BOXED_Feature_12", "BOXED_Feature_12",
"BOXED_Feature_12", "BOXED_Feature_4"), pid.avg_rw = c(2140,
1845.6, 1884.4, 1242.8, 1088.4, 973.6, 1160.4, 887.6, 910.8,
929.2), avg_rw_grade = c(1805.81052631579, 1805.81052631579,
1686.41503416856, 1286.07368421053, 1286.07368421053, 1148.48656036446,
1033.36421052632, 1033.36421052632, 982.933485193622, 1001.18526315789
), sd_grade = c(953.763652869694, 953.763652869694, 1156.80345459324,
397.333847576144, 397.333847576144, 478.193844053012, 247.762635541793,
247.762635541793, 742.892271389251, 247.504606484003)), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -10L))

R ggplot2 & gganimate: animation changes at end

I am trying to create this figure that animates over time using the gganimate library, going from the 'baseline' timepoint to the 'late' timepoint'. However for some reason, the image changes between frames 22-24 and again between 42-44. It throws off the visualization. But I am not sure how to fix it. Many thanks!
library(ggplot2)
library(tweenr)
library(gganimate)
library(treemapify)
set.seed(1)
colors <- c("turquoise", "gold", "yellowgreen", "dodgerblue", "firebrick", "orchid4",
"grey74", "forestgreen", "deeppink2", "grey0", "slateblue", "sienna2",
"khaki2", "steelblue", "darksalmon", "darksalmon")
tweened <- tween_states(list(PID50baseline, PID50late, PID50baseline),
tweenlength = 8, statelength = 8,
ease = 'cubic-in-out', nframes = 50)
animated_plot <- ggplot(tweened,
aes(area = Number, fill = Cluster.Name,
subgroup=Type, frame = .frame)) +
geom_treemap(fixed = T) +
geom_treemap_subgroup_border(fixed = T) +
geom_treemap_subgroup_text(place = "centre", grow = T, alpha = 0.5,
colour = "black", fontface = "italic",
min.size = 0,fixed = T) +
scale_fill_manual(values = colors) +
theme(legend.position = "bottom")
animation::ani.options(interval = 1/10)
gganimate(animated_plot, "animated_treemap_PID50.gif", title_frame = T,
ani.width = 200, ani.height = 200)
The data I used for this:
dput(PID50baseline)
structure(list(Cluster.Name = structure(c(13L, 14L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 15L, 15L), .Label = c("Cluster
13", "Cluster 14", "Cluster 17", "Cluster 18", "Cluster 19", "Cluster 20",
"Cluster 27", "Cluster 35", "Cluster 36", "Cluster 40", "Cluster 41",
"Cluster 42", "Cluster 5", "Cluster 6", "Non-clonal"), class = "factor"),
Number = c(5L, 9L, 0L, 0L, 1L, 2L, 0L, 2L, 3L, 2L, 1L, 0L,
0L, 0L, 1L, 28L), Type = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L), .Label = c("Defective",
"Intact"), class = "factor")), .Names = c("Cluster.Name",
"Number", "Type"), class = "data.frame", row.names = c(NA, -16L))
dput(PID50late)
structure(list(Cluster.Name = structure(c(13L, 14L, 1L, 2L, 3L,
4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 15L, 15L), .Label = c("Cluster 13",
"Cluster 14", "Cluster 17", "Cluster 18", "Cluster 19", "Cluster 20",
"Cluster 27", "Cluster 35", "Cluster 36", "Cluster 40", "Cluster 41",
"Cluster 42", "Cluster 5", "Cluster 6", "Non-clonal"), class = "factor"),
Number = c(2L, 10L, 2L, 2L, 1L, 0L, 5L, 0L, 5L, 0L, 3L, 3L,
2L, 2L, 18L, 59L), Type = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L), .Label = c("Defective",
"Intact"), class = "factor")), .Names = c("Cluster.Name",
"Number", "Type"), class = "data.frame", row.names = c(NA, -16L))
I believe treemapify omits areas with a size of 0. This could be the reason for your problem. In other words, replacing 0 with a small positive value greater than 0 (and using 16 distinct colors) gives you something like this:
tweened$Number[tweened$Number==0] <- 1e-10
colors <- unname(randomcoloR::distinctColorPalette(nlevels(tweened$Cluster.Name)))

Reverse fill order of stacked bars with faceting

I can't figure out how to get the fill order to reverse. Basically, I'm trying to get the guide and the fill to match an intrinsic order of the words from positive to negative:
The guide, and the fill order, from top to bottom should be:
"Far better than I expected", (Filled at very top, at top of legend)
"A little better than I expected",
"About what I expected",
"A little worse than I expected",
"Far worse than I expected" (Filled at very bottom, at bottom of legend)
You'll need sample data:
dat <- structure(list(Banner = structure(c(2L, 2L, 2L, 2L, 2L, 1L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 2L, 1L, 1L, 1L, 1L, 1L), .Label = c("Other", "Some Company"
), class = "factor"), Response = structure(c(1L, 2L, 3L, 4L,
5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L,
1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L),
.Label = c(
"Far better than I expected",
"A little better than I expected",
"About what I expected",
"A little worse than I expected",
"Far worse than I expected"), class = "factor"), Frequency = c(1L,
6L, 9L, 0L, 0L, 29L, 71L, 149L, 32L, 6L, 1L, 7L, 16L, 1L, 0L,
38L, 90L, 211L, 24L, 6L, 0L, 0L, 8L, 1L, 1L, 6L, 13L, 109L, 35L,
9L), Proportion = c(6, 38, 56, 0, 0, 10, 25, 52, 11, 2, 4, 28,
64, 4, 0, 10, 24, 57, 7, 2, 0, 0, 80, 10, 10, 3, 8, 63, 20, 5
), Phase = c("Phase 1", "Phase 1", "Phase 1", "Phase 1", "Phase 1",
"Phase 1", "Phase 1", "Phase 1", "Phase 1", "Phase 1", "Phase 2",
"Phase 2", "Phase 2", "Phase 2", "Phase 2", "Phase 2", "Phase 2",
"Phase 2", "Phase 2", "Phase 2", "Phase 3", "Phase 3", "Phase 3",
"Phase 3", "Phase 3", "Phase 3", "Phase 3", "Phase 3", "Phase 3",
"Phase 3")), .Names = c("Banner", "Response", "Frequency", "Proportion",
"Phase"),
row.names = c(NA, 30L),
sig = character(0),
comment = "Overall, my experience was... by Company", q1 = "", q2 = "",
class = c("survcsub", "data.frame"))
Position labels
dat <- ddply(dat, .(Banner, Phase), function(x) {
x$Pos <- (cumsum(x$Proportion) - 0.5*x$Proportion)
x
})
Plot
ggplot(dat, aes(Banner, Proportion/100, fill=Response,
label=ifelse(Proportion > 5, percent(Proportion/100), ""))) +
geom_bar(position="fill", stat="identity") +
geom_text(aes(Banner, Pos/100)) +
facet_grid(~Phase) +
scale_y_continuous(labels=percent) +
labs(x="\nCompany", y="\nProportion")
What I've tried:
dat$Response <- factor(dat$Response, levels=rev(dat$Response))
# No dice, reverses the colour of the scale but not the position of the fill
To change the order of values in stacked barplot you should use argument order= in aes() of geom_bar() and set name of column necessary for ordering (in this case Response). With function desc() you can set reverse order of bars.
Using your original data frame (without last line of factor()).
ggplot(dat, aes(Banner, Proportion/100, fill=Response,
label=ifelse(Proportion > 5, percent(Proportion/100), ""))) +
geom_bar(position="fill", stat="identity",aes(order=desc(Response))) +
geom_text(aes(Banner, Pos/100)) +
facet_grid(~Phase) +
scale_y_continuous(labels=percent) +
labs(x="\nCompany", y="\nProportion")
To get correct placement of labels, changed calculation of positions:
dat <- ddply(dat, .(Banner, Phase), function(x) {
x$Pos <- (100-cumsum(x$Proportion) + 0.5*x$Proportion)
x
})

Resources