Reputation: 11
The labeling_args parameter appears to be returning NULL, and the reason for this behavior eludes me.
Additionally, despite attempting to specify colors for both countries, the plot only assigns color to Italy, not to China. I'm unsure why this discrepancy exists.
library(vcd)
data <- matrix(c(43649, 7669, 1023, 357), nrow = 2, byrow = TRUE)
rownames(data) <- c("China", "Italy")
colnames(data) <- c("Survivor", "Death")
largs <- list(set_varnames = list(Country = rownames(data), Result = colnames(data)))
mosaic(data,
labeling_args = largs,
shade = TRUE,
main = "Mosaicplot for COVID-19 Data",
xlab = "Result", ylab = "Country", legend = FALSE)
Upvotes: 1
Views: 65
Reputation: 56179
Try this to fix the labels:
largs <- list(set_varnames = c(A = "Country", B = "Result"))
mosaic(data,
labeling_args = largs,
shade = TRUE,
main = "Mosaicplot for COVID-19 Data",
xlab = "Result", ylab = "Country")
To change the colours see this post
Upvotes: 0