I want to create a violin plot in R, for the math averages (y axis) depending on the level (x axis).
The problem is that I want my violin plot to be split and contain, for each level, the averages for female on one side and male on another (which account for 2 different columns in my data frame).
This is my data:
structure(list(section.name = structure(1:19, .Label = c("a",
"b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s "), class = "factor"), level = structure(c(1L,
2L, 4L, 3L, 2L, 4L, 5L, 1L, 1L, 3L, 4L, 2L, 5L, 1L, 2L, 4L, 3L,
1L, 5L), .Label = c("level 0 ", "level 1", "level 2", "level 3",
"level 4"), class = "factor"), math.av.females = c(62L, 72L,
49L, 57L, 64L, 78L, 81L, 63L, 68L, 74L, 70L, 64L, 80L, 67L, 70L,
72L, 80L, 78L, 64L), math.av.males = c(58L, 85L, 58L, 55L, 62L,
76L, 76L, 61L, 66L, 76L, 68L, 66L, 82L, 59L, 75L, 68L, 78L, 75L,
61L)), class = "data.frame", row.names = c(NA, -19L))