> x <- data.frame(a = rnorm(10), b = rnorm(10), c = rnorm(10))
> x
a b c
1 -1.09651022 -0.7416278 0.209405373
2 1.53644398 -0.9463432 0.374955227
3 1.71132675 -0.3828052 2.024143398
4 -1.10622882 -0.3599187 -0.808780103
5 -0.49616562 0.7061180 0.644142118
6 -1.75452442 0.3890812 -0.623815889
7 0.06315648 0.5103820 -1.501873998
8 0.64856129 -1.0973679 1.432024595
9 -0.62828873 -0.3159317 0.183674189
10 -0.82657934 1.6376569 -0.003601196
> rownames(x) <- as.Date(Sys.Date() - 9:0)
> x
a b c
2013-06-07 -1.09651022 -0.7416278 0.209405373
2013-06-08 1.53644398 -0.9463432 0.374955227
2013-06-09 1.71132675 -0.3828052 2.024143398
2013-06-10 -1.10622882 -0.3599187 -0.808780103
2013-06-11 -0.49616562 0.7061180 0.644142118
2013-06-12 -1.75452442 0.3890812 -0.623815889
2013-06-13 0.06315648 0.5103820 -1.501873998
2013-06-14 0.64856129 -1.0973679 1.432024595
2013-06-15 -0.62828873 -0.3159317 0.183674189
2013-06-16 -0.82657934 1.6376569 -0.003601196
> class(x)
[1] "data.frame"
> boxplot(x)
> xx <- as.xts(x, order.by = as.Date(rownames(x)))
> xx
a b c
2013-06-07 -1.09651022 -0.7416278 0.209405373
2013-06-08 1.53644398 -0.9463432 0.374955227
2013-06-09 1.71132675 -0.3828052 2.024143398
2013-06-10 -1.10622882 -0.3599187 -0.808780103
2013-06-11 -0.49616562 0.7061180 0.644142118
2013-06-12 -1.75452442 0.3890812 -0.623815889
2013-06-13 0.06315648 0.5103820 -1.501873998
2013-06-14 0.64856129 -1.0973679 1.432024595
2013-06-15 -0.62828873 -0.3159317 0.183674189
2013-06-16 -0.82657934 1.6376569 -0.003601196
> class(xx)
[1] "xts" "zoo"
> boxplot(xx)
Error in try.xts(c(2.12199579096527e-314, 2.12199579096527e-314, 0, 2.12199579096527e-314, :
Error in xts(coredata(x), order.by = index(x), .CLASS = "xts", ...) : order.by requires an appropriate time-based object
>
もちろん...
> boxplot(as.matrix(xx), col = "red")
大きな問題ではありませんが、毎回 xts を強制する必要はありません。または、より一般的には、これにより明らかになる可能性のある他の問題がある場合に備えて、ここで何が起こっているのかを知りたいです。