2015-09-30 59 views
0

我使用beeswarm來繪製我的數據。如何更改散熱圖的離散x軸的順序?

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

這產生了以下圖像。

enter image description here

我如何可以手動指定x軸,使WT來KO過嗎?

+0

使之成爲一個因素,並設置相應的水平。 – Heroka

+0

對不起,我應該提到我的知識幾乎沒有。你能寫一些我可以嘗試的特定代碼嗎? – Sparhawk

+0

是的,這是一個騙局。我只是不知道要搜索什麼。 FWIW下面的答案工作。謝謝您的幫助。 – Sparhawk

回答

1
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

1

這是一個很多關於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)