使用xyplot时,以数字顺序获取轴而不是字母顺序

时间:2015-02-24 00:52:23

标签: r lattice

我有以下数据框:

interest       field1           date
1       0.191          3   January 2014
2        0.06          5   January 2014
3       0.012          7   January 2014
4           0         10   January 2014
5        0.01         15   January 2014
6        0.01         30   January 2014
7           0         60   January 2014
8           0         90   January 2014
9           0        999   January 2014
10      0.228          3  February 2014
11          0          5  February 2014
12      0.025          7  February 2014
13      0.031         10  February 2014
14      0.009         15  February 2014
15      0.005         30  February 2014
16          0         60  February 2014
17      0.012         90  February 2014
18      0.016        999  February 2014
19      0.205          3     March 2014
20      0.018          5     March 2014
21      0.013          7     March 2014
22          0         10     March 2014
23          0         15     March 2014
24      0.005         30     March 2014
25      0.004         60     March 2014
26      0.011         90     March 2014
27          0        999     March 2014
28      0.206          3     April 2014
29      0.034          5     April 2014
30      0.011          7     April 2014
31      0.029         10     April 2014
32       0.02         15     April 2014
33      0.006         30     April 2014
34          0         60     April 2014
35      0.009         90     April 2014
36          0        999     April 2014
37      0.281          3       May 2014
38      0.073          5       May 2014
39      0.069          7       May 2014
40      0.035         10       May 2014
41       0.01         15       May 2014
42      0.006         30       May 2014
43      0.013         60       May 2014
44      0.009         90       May 2014
45          0        999       May 2014
46      0.264          3      June 2014
47      0.078          5      June 2014
48      0.026          7      June 2014
49      0.024         10      June 2014
50       0.03         15      June 2014
51      0.005         30      June 2014
52          0         60      June 2014
53          0         90      June 2014
54          0        999      June 2014
55      0.179          3      July 2014
56      0.064          5      July 2014
57      0.026          7      July 2014
58      0.027         10      July 2014
59      0.011         15      July 2014
60      0.006         30      July 2014
61          0         60      July 2014
62      0.011         90      July 2014
63          0        999      July 2014
64       0.27          3    August 2014
65      0.072          5    August 2014
66      0.031          7    August 2014
67      0.018         10    August 2014
68      0.009         15    August 2014
69      0.017         30    August 2014
70      0.005         60    August 2014
71          0         90    August 2014
72          0        999    August 2014
73      0.216          3 September 2014
74       0.03          5 September 2014
75      0.045          7 September 2014
76      0.054         10 September 2014
77       0.02         15 September 2014
78      0.011         30 September 2014
79          0         60 September 2014
80          0         90 September 2014
81          0        999 September 2014
82      0.253          3   October 2014
83      0.037          5   October 2014
84      0.065          7   October 2014
85      0.049         10   October 2014
86      0.018         15   October 2014
87          0         30   October 2014
88      0.012         60   October 2014
89          0         90   October 2014
90          0        999   October 2014
91      0.219          3  November 2014
92      0.061          5  November 2014
93      0.007          7  November 2014
94      0.033         10  November 2014
95      0.006         15  November 2014
96      0.015         30  November 2014
97      0.004         60  November 2014
98          0         90  November 2014
99          0        999  November 2014
100     0.214          3  December 2014
101     0.047          5  December 2014
102     0.018          7  December 2014
103     0.008         10  December 2014
104     0.006         15  December 2014
105     0.012         30  December 2014
106         0         60  December 2014
107         0         90  December 2014
108         0        999  December 2014
109       0.3          3   January 2015
110     0.026          5   January 2015
111     0.018          7   January 2015
112     0.025         10   January 2015
113         0         15   January 2015
114     0.014         30   January 2015
115     0.003         60   January 2015
116         0         90   January 2015
117         0        999   January 2015

我希望能够根据日期对兴趣与字段1进行分组。但是,当我尝试以下代码时:

xyplot(as.numeric(interest)~(field1),Rates,groups=date,type="l",main = "title",auto.key=TRUE)

example

问题是x轴不是按数字顺序排列,而是按字母顺序排列。有人告诉我,我可以通过在x轴数字上设置变量来解决这个问题,这就是我在代码中使用as.numeric函数的原因。但这没效果。有什么建议?这似乎应该是绘制数值变量的默认值,但我不能为我的生活弄清楚如何让它以数字方式对点进行排序。任何帮助将不胜感激!

0 个答案:

没有答案