I'm trying to do a split Violin Plot or Beanplot. I'd like it to look somewhat similar to the plot on page 6 of the link below with the following changes:
Market <- c('SG', 'SG', 'SG', 'SG', 'SG', 'SG', 'SG', 'SG', 'Ind', 'Ind', 'Ind', 'Ind','Ind', 'Ind', 'Ind', 'Ind')
Prem <- c(400, 405, 433, 450, 420, 422, 415, 444, 351, 363, 387, 371, 350, 360, 375, 388)
Exchange <- c('On','On','On', 'On', 'On','On','On', 'On', 'Off', 'On', 'Off', 'On', 'Off', 'On', 'Off', 'On')
df <- data.frame(Market, Prem, Exchange)
attach(df)
data <- split(Prem, Market)
library(ggplot2)
library(vioplot)
library(beanplot)
names(data)[1] <- 'x'
do.call("vioplot", c(data, list(names = levels(Market), col = "white")))
par(mfrow = c(1,1))
par(lend=1)
beanplot(Prem~Market, data = df, col = list("black", c("grey", "white")))
I know 'side' in the beanplot function creates an asymmetric beanplot, but I'd like to keep the Markets separate and have them split by the variable exchange.