1

I'm using beeswarm to plot my data.

d<-data.frame(Cond=c(WT,WT,KO,KO),Count=c(1,2,3,4))
beeswarm(Count ~ Cond, data = d)

This produces the following image.

enter image description here

How can I manually specify the x-axis, so that WT comes before KO?

Sparhawk
  • 1,581
  • 1
  • 19
  • 29
  • Make it into a factor and set the levels accordingly. – Heroka Sep 30 '15 at 10:37
  • Sorry, I should have mentioned that my r knowledge is next to nothing. Could you please write some specific code that I can try? – Sparhawk Sep 30 '15 at 10:40
  • Yep, it was a dupe. I just didn't know what to search for. FWIW the answers below worked. Thanks for the help. – Sparhawk Sep 30 '15 at 10:45

2 Answers2

2
d<-data.frame(Cond=c("WT","WT","KO","KO"),Count=c(1,2,3,4))

#turn into a factor with manual specification of levels
d$Cond <- factor(d$Cond,levels=c("WT","KO"))


#plot
beeswarm(Count ~ Cond, data = d)

enter image description here

Heroka
  • 12,889
  • 1
  • 28
  • 38
1

It was a lot about that here

d<-data.frame(Cond=c('WT', 'WT', 'KO', 'KO'),Count=c(1,2,3,4))
    library(beeswarm)

    beeswarm(Count ~ Cond, data = d)

    f <- ordered(d$Cond, levels = c("WT", "KO"))
    beeswarm(Count ~ f, data = d)
Community
  • 1
  • 1
Mateusz1981
  • 1,817
  • 17
  • 33