2016-04-07 168 views
1

我不能強迫R用x軸以升序繪製我的數據。當我繪製該數據中,x軸是在順序1,10,11,12,2,3,...R ggplot2 X軸繪製爲水平

library(ggplot2) 
BradfordProteinData<-read.csv(normalizePath('data/ch3/bpa.csv')) 
BPD<-BradfordProteinData[-(1),] 
xx<-BPD[,1] 
yy<-BPD[,3] 
xx 
yy 
par(mar=c(1,1,1,1)) 
ggplot(BPD) + geom_point(aes(x=Hour, y=OD600)) 
qplot(xx,yy, geom = c("point", "smooth")) 
qplot(sort(Hour, decreasing=FALSE), OD600, data = BPD, geom = c("point", "smooth")) 

xxyyclass(xx) # factor。 我的SE點太低,無法插入圖片,但這裏是我爲.csv

Hour,OD600,OD600,OD600,Average,StdDev 
Hour,R1,R2,R3,Average,StdDev 
1,0.037,0.040,0.031,0.036,0.003 
2,0.048,0.044,0.042,0.044,0.002 
3,0.097,0.091,0.093,0.093,0.002 
4,0.0286,0.320,0.331,0.226,0.140 
5,1.272,1.099,1.29,1.220,0.086 
6,1.71,2.476,2.058,2.081,0.313 
7,2.606,3.08,2.818,2.834,0.193 
8,3.614,3.806,3.808,3.742,0.090 
9,4.594,5.221,4.933,4.916,0.256 
10,5.364,5.31,6.32,5.664,0.463 
11,6.812,6.741,5.102,6.218,0.789 
12,5.151,6.649,4.908,5.569,0.769 

回答

0

數據嘗試

sort(as.numeric(Hour), decreasing=FALSE) 

這是你的字符串「10」,「11」將因此被視爲數字按數值排序而不是字符串值