I am new to using TramineR and I just cannot seem to figure out how to arrange the legend in any of the plot types. The legend keeps being cut off by the plots. I have tried to use the seqlegend command but I do not understand how I would integrate the separate legend into my plots.
dat <- data.frame(matrix(sample(0:13, 300 * 26, replace = TRUE), ncol = 26))
dat$age50 <- sample(c("yes", "no"), 300, replace = TRUE)
# Create state sequence object
cci.seq <- seqdef(dat,
var = 1:26,
alphabet = c("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "99"))
# Recode the sequence object
cci.new <- seqrecode(cci.seq,
recodes = list("0 CCI" = "0",
"1-2 CCI" = c("1", "2"),
"3-4 CCI" = c("3", "4"),
"5-6 CCI" = c("5", "6"),
"7-8 CCI" = c("7", "8"),
"10+ CCI" = c("9", "10", "11", "12", "13"),
"death" = c("99")))
# Define color palette
cpal(cci.new) <- c("#CAE1EE", "#0772b4", "#f2c673", "#df3337", "#f29862", "#2fa791", "#8A2BE2")
# Basic plot
seqIplot(cci.new,
with.legend = TRUE,
bty = "n",
idxs = 1:300,
group = dat$age50,
legend.prop = 0.1,
ncol=2,
main = "300 individual sequences by disability status")
I have tried adjusting the cex.legend but it makes the text too small to read.