Reputation: 21
How can I obtain something similar to a mosaic plot but representing just the information from a frequency table for a single variable?
mosaicplot(table(my_var)) works fine, but only shows vertical bars.
Is it possible to obtain a mosaic plot like a puzzle of different tiles instead of just vertical bars? Something similar to this image:
Upvotes: 1
Views: 209
Reputation: 4242
As @Man.A noted, you can create a treemap with the treemap
R package. A simple example:
# library
library(treemap)
#> Warning: package 'treemap' was built under R version 4.1.3
# Create data
group <- c("group-1","group-2","group-3")
value <- c(13,5,22)
data <- data.frame(group,value)
# treemap
treemap(data,
index="group",
vSize="value",
type="index"
)
Upvotes: 0