在我最近的问题中,我在使用不同的库时遇到了与轴有关的问题。
在这种特殊情况下,我使用相同的数据集,其中 X 中存在的变量只有两个可能的值 - 2009 或 2010。
2009,01,52.4
2009,01,49.5
2009,01,53.2
2009,01,48.2
2009,01,53.9
2009,01,42.8
2009,01,56.4
2009,01,57
2009,01,50.3
2009,01,57.4
2009,01,45.2
2009,01,55
2009,01,47.1
2009,01,42.2
2009,01,57.1
2009,01,51.7
2009,01,56.8
2009,01,56.9
2009,01,55
2009,01,52.9
2009,01,52.9
2009,01,57
2009,01,45
2009,01,52.8
2009,01,52
2009,01,55.1
2009,01,53.3
2009,01,55.2
2009,01,53.2
2009,01,56.9
2009,01,55.9
2009,02,54.7
2009,02,53.1
2009,02,54.2
2009,02,56.2
2009,02,58.5
2009,02,50.9
2009,02,57.7
2009,02,54.1
2009,02,54.5
2009,02,55.3
2009,02,53.4
2009,02,53.8
2009,02,51.3
2009,02,52.3
2009,02,53
2009,02,53.6
2009,02,55
2009,02,53
2009,02,53.6
2009,02,52.5
2009,02,54.1
2009,02,50.1
2009,02,52.2
2009,02,54.3
2009,02,52.4
2009,02,53.2
2009,02,52.5
2009,02,52.7
2009,03,56.2
2009,03,58.7
2009,03,58.2
2009,03,63
2009,03,55
2009,03,55.4
2009,03,55.8
2009,03,63.8
2009,03,56
2009,03,52.3
2009,03,55.6
2009,03,56.8
2009,03,57.4
2009,03,58.7
2009,03,59.9
2009,03,57.7
2009,03,55.3
2009,03,54.9
2009,03,61.8
2009,03,54.1
2009,03,52.9
2009,03,55.5
2009,03,55.3
2009,03,66.4
2009,03,55.7
2009,03,53.2
2009,04,55.4
2009,04,60
2009,04,54.9
2009,04,55.3
2009,04,57.5
2009,04,55.8
2009,04,57.6
2009,04,55.7
2009,04,56.4
2009,04,54
2009,04,55.8
2009,04,56.8
2009,04,54.8
2009,04,55.8
2009,04,55.8
2009,04,53.5
2009,04,56.8
2009,04,54
2009,04,56.7
2009,04,57.2
2009,04,57.8
2009,04,57.3
2009,04,57.2
2009,04,57.2
2009,04,56.2
2009,04,55.2
2009,04,54.7
2009,04,57
2009,04,55.9
2009,05,59.8
2009,05,58.9
2009,05,59.3
2009,05,58.9
2009,05,60.4
2009,05,59.1
2009,05,58.5
2009,05,73.4
2009,05,62.5
2009,05,61.4
2009,05,61.1
2009,05,61.6
2009,05,67.6
2009,05,66.5
2009,05,58.6
2009,05,61.1
2009,05,62
2009,05,72.1
2009,05,59.3
2009,05,59.6
2009,05,61
2009,05,57.1
2009,05,59.2
2009,05,60.4
2009,05,60.1
2009,05,58.5
2009,05,58.9
2009,05,59.8
2009,05,62.6
2009,05,60.9
2009,05,59.5
2009,06,63.8
2009,06,65.4
2009,06,64.7
2009,06,64
2009,06,65.8
2009,06,68.3
2009,06,63.9
2009,06,64.2
2009,06,61.9
2009,06,62.9
2009,06,63.9
2009,06,69.7
2009,06,63.7
2009,06,63.4
2009,06,63.8
2009,06,64.5
2009,06,64.4
2009,06,63.9
2009,06,66.6
2009,06,70.3
2009,06,67.1
2009,06,65.8
2009,06,65.5
2009,06,62.9
2009,06,64.4
2009,06,65.4
2009,06,64.4
2009,06,63.3
2009,06,66.3
2009,06,66.7
2009,07,64.8
2009,07,66
2009,07,66.8
2009,07,69.9
2009,07,65.9
2009,07,68.6
2009,07,67.6
2009,07,66.7
2009,07,65.5
2009,07,65
2009,07,66.5
2009,07,66.7
2009,07,67.1
2009,07,67.4
2009,07,64.8
2009,07,65.8
2009,07,64.7
2009,07,66
2009,07,68
2009,07,66
2009,07,64.1
2009,07,65.8
2009,07,65
2009,07,63.3
2009,08,65.9
2009,08,65
2009,08,65.9
2009,08,64
2009,08,66.1
2009,08,64.5
2009,08,64
2009,08,66.8
2009,08,65
2009,08,64.7
2009,08,64.8
2009,08,65.8
2009,08,64.9
2009,08,64.9
2009,08,65.1
2009,08,65.2
2009,08,67
2009,08,64.8
2009,08,65.6
2009,08,66.1
2009,08,64.9
2009,08,67.1
2009,08,64.7
2009,08,64.9
2009,08,65.1
2009,08,64.1
2009,08,64.6
2009,08,66.5
2009,08,65.4
2009,08,65
2009,09,64.2
2009,09,63.1
2009,09,65.3
2009,09,64.2
2009,09,64.7
2009,09,63.9
2009,09,70.9
2009,09,70.1
2009,09,65
2009,09,65.5
2009,09,65.4
2009,09,68.1
2009,09,64.4
2009,09,65.1
2009,09,65.7
2009,09,63.2
2009,09,64.5
2009,09,64.8
2009,09,66.4
2009,09,64.9
2009,09,67.5
2009,09,66.4
2009,09,65.7
2009,09,65
2009,09,64.4
2009,09,62.5
2009,09,62.9
2009,09,63.7
2009,09,63.3
2009,10,66.6
2009,10,62.9
2009,10,63.1
2009,10,65.4
2009,10,69.4
2009,10,71.1
2009,10,64.1
2009,10,66.9
2009,10,69.4
2009,10,66.6
2009,10,63
2009,10,67.2
2009,10,68.6
2009,10,65.2
2009,10,64
2009,10,62.4
2009,10,65
2009,10,64.3
2009,10,68.6
2009,10,68
2009,10,63
2009,10,61.2
2009,10,65.3
2009,10,64.7
2009,10,67.1
2009,10,67.2
2009,10,68.5
2009,10,65.4
2009,10,64
2009,11,58.4
2009,11,66.4
2009,11,58.2
2009,11,55.7
2009,11,59.4
2009,11,62.7
2009,11,61.5
2009,11,62.2
2009,11,63.8
2009,11,62.2
2009,11,59.9
2009,11,62.5
2009,11,61.8
2009,11,63.3
2009,11,60.5
2009,11,60
2009,11,62
2009,11,60.5
2009,11,59.4
2009,11,63
2009,11,61.8
2009,11,60.6
2009,11,62.2
2009,11,62.9
2009,11,59.3
2009,11,55.6
2009,11,61.2
2009,11,57.6
2009,11,63.3
2009,11,58.1
2009,12,45.6
2009,12,59.7
2009,12,59.4
2009,12,59.5
2009,12,58
2009,12,56.5
2009,12,60.3
2009,12,55.9
2009,12,50.6
2009,12,51.3
2009,12,62.3
2009,12,58.2
2009,12,40.6
2009,12,59.4
2009,12,55.6
2009,12,61.6
2009,12,48.1
2009,12,52.3
2009,12,57.7
2009,12,60.1
2009,12,61.3
2009,12,59.7
2009,12,52.6
2009,12,51.9
2009,12,53.2
2009,12,58.7
2009,12,55.9
2010,01,57.8
2010,01,45.4
2010,01,50.5
2010,01,56.3
2010,01,58.1
2010,01,41.8
2010,01,53
2010,01,58.9
2010,01,52.5
2010,01,50.5
2010,01,56.4
2010,01,55.9
2010,01,55.4
2010,01,39
2010,01,56.4
2010,01,57.7
2010,01,59.8
2010,01,54.9
2010,01,56.1
2010,01,55.6
2010,01,57.5
2010,01,47.4
2010,01,59.5
2010,01,48.7
2010,01,59.4
2010,01,55.5
2010,01,56.3
2010,01,45.1
2010,01,49
2010,02,43.1
2010,02,53.9
2010,02,44.2
2010,02,53.2
2010,02,48.8
2010,02,44.3
2010,02,57.3
2010,02,50.4
2010,02,59.8
2010,02,58.5
2010,02,56.3
2010,02,56.7
2010,02,58.9
2010,02,51.3
2010,02,43
2010,02,58.4
2010,02,56.9
2010,02,57.2
2010,02,51.2
2010,02,50.9
2010,02,48.7
2010,02,54.4
2010,02,55.9
2010,02,53.9
2010,02,59.3
2010,03,56
2010,03,54.9
2010,03,55.9
2010,03,58.2
2010,03,60.9
2010,03,56
2010,03,57.5
2010,03,59.1
2010,03,57.4
2010,03,51.9
2010,03,58
2010,03,55.9
2010,03,57.1
2010,03,55
2010,03,60.7
2010,03,55.7
2010,03,50.3
2010,03,57.6
2010,03,60.5
2010,03,53.7
2010,03,56.5
2010,03,57.3
2010,03,52.8
2010,03,46.7
2010,03,52.3
2010,03,55.6
2010,03,52.7
2010,03,56.1
2010,03,57.1
2010,03,55.2
2010,03,57.6
2010,04,62.4
2010,04,62.6
2010,04,55.7
2010,04,62.5
2010,04,57.5
2010,04,69.5
2010,04,63.5
2010,04,62.2
2010,04,60.7
2010,04,62.5
2010,04,62
2010,04,57.6
2010,04,61.3
2010,04,54.8
2010,04,64.3
2010,04,61.4
2010,04,67.2
2010,04,63
2010,04,64.5
2010,04,57.3
2010,04,57.4
2010,04,55.8
2010,04,58.6
2010,04,60.6
2010,04,61
2010,04,56.9
2010,04,60.2
2010,04,65.3
2010,04,60.2
2010,04,59.6
2010,05,73.9
2010,05,63.3
2010,05,56.5
2010,05,63.7
2010,05,63.2
2010,05,58.9
2010,05,58.1
2010,05,71.3
2010,05,63
2010,05,64.8
2010,05,64.1
2010,05,58.6
2010,05,55.9
2010,05,57.7
2010,05,69.1
2010,05,61.4
2010,05,59.2
2010,05,58.5
2010,05,57.3
2010,05,60.2
2010,05,59.1
2010,05,67.8
2010,05,67.1
2010,05,64.7
2010,05,61.3
2010,05,58.5
2010,05,58.7
2010,05,61.7
2010,05,59.9
2010,05,65.2
2010,06,64.4
2010,06,62
2010,06,62.2
2010,06,62.7
2010,06,65.8
2010,06,65.1
2010,06,63.4
2010,06,63.3
2010,06,62.2
2010,06,61.8
2010,06,61.5
2010,06,61.7
2010,06,64.7
2010,06,62.8
2010,06,64.2
2010,06,61.4
2010,06,63.3
2010,06,62.8
2010,06,64.1
2010,06,60.5
2010,06,62.6
2010,06,62.2
2010,06,63.1
2010,06,62.9
2010,06,63
2010,06,62.5
2010,06,62.2
2010,06,63.9
2010,06,61.9
2010,06,64.3
2010,07,65
2010,07,65.3
2010,07,65.1
2010,07,65.6
2010,07,65.6
2010,07,69.8
2010,07,74.5
2010,07,64.7
2010,07,65.6
2010,07,64.6
2010,07,72.1
2010,07,66.4
2010,07,66.8
2010,07,63.7
2010,07,65.2
2010,07,63.8
2010,07,65
2010,07,66.5
2010,07,65.4
2010,07,67.1
2010,07,65.5
2010,07,66.3
2010,07,65.9
2010,07,65.5
2010,07,64.5
2010,07,65
2010,07,65.9
2010,07,64.8
2010,07,65.3
2010,07,64.8
2010,07,65.3
2010,08,65.6
2010,08,65.5
2010,08,67
2010,08,69.4
2010,08,65
2010,08,64.3
2010,08,66.9
2010,08,65.4
2010,08,64.4
2010,08,65.1
2010,08,66.4
2010,08,63.6
2010,08,65.2
2010,08,63.3
2010,08,70.1
2010,08,65.9
2010,08,68.3
2010,08,67.8
2010,08,64.4
2010,08,65.1
2010,08,64.7
2010,08,63.7
2010,08,63.5
2010,08,67.9
2010,08,70.3
2010,08,65.8
2010,08,63.9
2010,08,66.6
2010,08,67.4
2010,08,65.4
2010,08,64.1
2010,09,66.6
2010,09,70.7
2010,09,66.3
2010,09,64.5
2010,09,66.7
2010,09,68.1
2010,09,71.2
2010,09,64.4
2010,09,65
2010,09,67.8
2010,09,64.5
2010,09,66.7
2010,09,67.8
2010,09,67.6
2010,09,68.3
2010,09,67.8
2010,09,67.6
2010,09,66.4
2010,09,68.4
2010,09,67.6
2010,09,63.7
2010,09,72.2
2010,09,67.3
2010,09,67.6
2010,09,67.6
2010,09,68.4
2010,09,64.7
2010,09,68.6
2010,09,66.4
2010,10,62
2010,10,63.3
2010,10,63.6
2010,10,63.7
2010,10,61.8
2010,10,64.2
2010,10,62.9
2010,10,65.6
2010,10,64.1
2010,10,65.2
2010,10,64.8
2010,10,61.6
2010,10,64.7
2010,10,65.7
2010,10,60.9
2010,10,61.7
2010,10,65.1
2010,10,65.5
2010,10,61
2010,10,62.1
2010,10,63
2010,10,65.8
2010,10,64.3
2010,10,65.3
2010,10,64.8
2010,10,62.5
2010,10,60.7
2010,11,61.2
2010,11,60.4
如果我运行以下代码
library(plot3D)
heisenberg <- read.csv(file="ABSOLUTE_FILE_LOCATION")
x <- heisenberg[[1]]
y <- heisenberg[[2]]
z <- heisenberg[[3]]
points3D(x, y, z, ticktype = "detailed")
我明白了
问题是,我希望 X 轴只有 2009 和 2010 而不是 2009.0、2009.2、2009.4 ...
加入latticeExtra
一个因素解决了这个问题。
就像在另一个问题中一样,如果我在数据中添加两个条目,我可以获得以下结果,这比我想要的更接近但引入了错误的数据。
所以,我决定以类似的方式添加因子,就像解决另一个因子一样,我收到以下错误
Math.factor(diff(xlim)) 中的错误:“abs”对因子没有意义
这个错误意味着我正在应用abs()
一个对象类型因子并且它不喜欢。
考虑到该函数factor()
允许我为名义变量分配顺序,从而使它们成为序数变量,如果我将因子转换为整数预计不会解决这个问题,我会得到相同的结果
library(plot3D)
heisenberg <- read.csv(file="ABSOLUTE_FILE_LOCATION")
x <- heisenberg[[1]]
x <- factor(x, levels = c(2009, 2010), ordered = TRUE)
x <- as.numeric(levels(x))[x]
y <- heisenberg[[2]]
z <- heisenberg[[3]]
points3D(x, y, z, ticktype = "detailed")
正如预期的那样。
那么,考虑到这种情况,我该怎么做才能解决这个问题?