How can I add additional labels mually to the swimmer plot using pplot2 in r?
How can I manually add additional labels to the diamonds (yellow and red)? Also, how can I add an additional label to the geometric line (name: "Baseline)?
# Data frame
df <- data.frame(subjectID = factor(1:10, 10:1),
stage = rep(c("exposed", "unexposed"), times = c(6, 4)),
startTime = 0,
endTime = c(6, 8, 1.7, 1.6, 2, 2, 2, 2, 1, 1.5),
isContinued = rep(c(!1, !1, !0, !0, !1), times = c(2, 2, 2, 2, 2)),
Outcome = rep(c("death", "discharge", "death", "discharge", NA, NA, NA, NA, "death", "discharge"), 1),
TreatmentStartTime=c(1.0, 1.5, 0.3, 0.9, NA, NA, NA, NA, NA, NA),
TreatmentEndTime=c(6.0, 7.0, 1.2, 1.4, NA, NA, NA, NA, NA, NA),
TimeZero=c(0,0,0,0,0,0,0,0,0,0),
ind=rep(c(!0, !0, !0, !0, !0), times = c(2, 2, 2, 2, 2)),
Garea=c(1.0, 1.5, 0.3, 0.9, 2, 2, NA, NA, NA, NA),
censoring=c(NA, NA, NA, NA, 2, 2, 2, 2, NA, NA))
# Plot
ggplot.t <- ggplot(df, aes(subjectID, endTime)) +
scale_fill_manual(values = c("blue", "red"))
geom_col(aes(fill = factor(stage))) +
geom_rect(aes(ymin = TimeZero, ymax = Garea, xmin = as.numeric(subjectID) - 0.45, # -0.45
xmax = as.numeric(subjectID) + 0.45), fill = 'gray',
data = df.t[df.t$ind,]) +
geom_point(data=df, aes(subjectID, TreatmentStartTime), colour = c("#FDE725FF"), fill =alpha(c("#FAFAFA"), 0.2), shape=18, size=6) +
coord_flip() +
geom_point(data=df, aes(subjectID, censoring), colour = c("#EF5350"), shape=18, size=6) +
coord_flip() +
geom_point(aes(colour = Outcome, shape = Outcome), size = 6) +
coord_flip() +
scale_colour_manual(values = c('#20A387FF','#95D840FF')) +
scale_y_continuous(limits = c(-0.2, 10), breaks = 0:10))
How many English words
do you know?
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
how many words do you know
Powered by Examplum