2013-03-11 46 views
0

我有一個數據幀如下令x軸(數月)

year month increment 
113 6 464 
113 7 132 
113 8 165 
113 9 43 
113 10 658 
113 11 54 
113 12 463 
114 1 231 
114 2 21 

儘管被下令指示,當我積增量〜因子(一個月),在圖中所產生的x軸從本月開始1,而不是用月6日起,如數據框

qplot(month,data=monthly,fill=treatment,weight=increment,position="dodge") 

我應該怎麼做才能讓x軸尊重一個月,我需要的順序?

+0

在一般情況下,爲了您的數據框中的數據具有_no connection_以顯示它的方式。 (也有例外,但很少見。) – joran 2013-03-11 02:57:26

+0

您的例子中缺少部分數據,即治療。如果它不存在,將如何填充=治療? – N8TRO 2013-03-11 03:01:06

+0

此外,即使您的年份列的格式很奇怪,您可能也想閱讀base中的'as.date'或一些非常有用的日期/時間包:'lubridate','chron'等。 – N8TRO 2013-03-11 03:08:14

回答

0

事情是這樣的,也許:

qplot(interaction(year, month, lex.order=TRUE), data=monthly, fill=treatment,weight=increment,position="dodge") 

卸下fill=treatment參數(因爲我沒有數據)的結果是:

qplot(interaction(year, month, lex.order=TRUE), data=monthly, weight=increment,position="dodge") 

enter image description here