I am trying to use this chunk of code to create a plot in R. I want to get one frame for each variable in Offensive_Statistic
with boxplots per each variable in Jet_Lag_boolean
representing the distributions in Measure
ggplot(data=df_off_plots, aes(y=Jet_Lag_boolean, x=Measure)) + geom_boxplot() +
xlab("Measurement Value")+
facet_wrap( ~ Offensive_Statistic, scales="free_y")+
theme_bw() + ylab(" Number of Time Zones Crossed") + coord_flip()
I am getting the overall structure correctly but my boxplots are only lines as you can seee here:
I am adding a reproducible dataset:
Data <- data.frame(
Measure = sample(0:999),
Jet_Lag_boolean = sample(c("1", "0"), 1000, replace = TRUE),
Offensive_Statistic = sample(c('OPA', 'OA', 'SLG'), 1000, replace = TRUE)
)
I am getting the same error: