0

I am trying to create a violin plot comparing genetic variant class against age at time of surgery and I am getting some very weird results.

I have been using the below guide, which makes creating violin plots look easy:

http://www.sthda.com/english/wiki/ggplot2-violin-plot-quick-start-guide-r-software-and-data-visualization

plot = ggplot(df,aes(x=factor(Category), y=age.at.time.of.surgery)) + 
              geom_violin()

Age at surgery for individuals with or without pathogenic variants

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
David Ross
  • 1,087
  • 1
  • 14
  • 21
  • 5
    your y variable is probably a factor or a character variable. Try transforming it to numeric or integer. `df$age.at.time.of.surgery <- as.numeric(as.character(df$age.at.time.of.surgery))` – scoa Aug 25 '16 at 11:37
  • Yep this works perfectly! Thank you – David Ross Aug 26 '16 at 15:28

0 Answers0