Home > Back-end >  Mosaicplot. Passing value to mosaic bars
Mosaicplot. Passing value to mosaic bars

Time:05-27

I am very new to R so would gladly take any advice. So I have a data frame like this:

     Year   Age     POF values
1  2019K1 15–24    town   10.8
2  2020K1 15–24    town   12.3
3  2021K1 15–24    town   11.6
4  2022K1 15–24    town   11.8
5  2019K1 25–54    town    5.1
6  2020K1 25–54    town    5.2
7  2021K1 25–54    town    6.2
8  2022K1 25–54    town    5.3
9  2019K1 55–64    town    6.6
10 2020K1 55–64    town    7.7
11 2021K1 55–64    town    7.9
12 2022K1 55–64    town    7.1
13 2019K1 15–24 village   15.0
14 2020K1 15–24 village   19.7
15 2021K1 15–24 village   14.1
16 2022K1 15–24 village   13.9
17 2019K1 25–54 village    7.8
18 2020K1 25–54 village    8.5
19 2021K1 25–54 village    8.0
20 2022K1 25–54 village    6.0
21 2019K1 55–64 village    9.3
22 2020K1 55–64 village   11.5
23 2021K1 55–64 village   12.8
24 2022K1 55–64 village   10.1

and I've been trying to plot it as mosaic, but I can't figure out why doesn't my mosaic take values from the data frame and apply them to bars based on data frame given.

this is my plot code:

mosaicplot(~ data$Year   data$Age   data$POF, data = data)

And this is how the plot ends up looking:

enter image description here

  •  Tags:  
  • r
  • Related