I have a table of 983 obs. of 27 variables; the data can be provided if need be, but I do not believe there is a need for it, as the following crosstable should summarise it well enough:
Kjønn Antall <> e f g s ug
Sex Count w d m s um
k 282 2 26 5 41 208
m 701 11 56 4 148 2 480
Abbreviations (with English translation):
e[nkemann], f[raskilt], g[ift], s[eparert], ug[ift]
w[idow(er)], d[ivorced], m[arried], s[eparated], u[n]m[arried]
I would like to create a variable width boxplot showing the distribution of these individuals, but as can be seen from the table, the NAs, the divorced and the separated would be such a small group that it would be hardly legible (and pointless. How can I join these groups creating a boxplot showing e
, f+s
, g
, and ug
?
My current code:
# The basis for the boxplot
dBox_SexAge <- ggplot(data = tblHoved) +
geom_boxplot(
mapping = aes(colour = KJONN, x = KJONN, y = 1875-FAAR),
notch = TRUE,
lwd = .5, fatten = .125,
varwidth = TRUE
)
# Create the final boxplot
dBox_SexAgeMStat <- dBox_SexAge +
facet_grid(SIVST ~ .) +
coord_flip()
# Run it
dBox_SexAgeMStat