r - As.XTS from Matrix - Error - Adds time and timezone info -


for reason not understand, when run as.xts convert matrix date in rownames, operation generate date time in end. since different start indexes merge/cbinds not work. can point me doing wrong?

> class(x) [1] "xts" "zoo" > head(x)            xly.adjusted xlp.adjusted xle.adjusted agg.adjusted ivv.adjusted 2005-07-31  0.042255791  0.017219585   0.17841600  0.010806168   0.04960026 2005-08-31  0.034117087  0.009951766   0.18476766  0.015245222   0.03825968 2005-09-30 -0.029594066  0.008697349   0.22851906  0.009769765   0.02944754 2005-10-31 -0.015653740  0.019966664   0.09314327 -0.012705172   0.01640395 2005-11-30 -0.005593003  0.005932542   0.05437377 -0.005209811   0.03173972 2005-12-31  0.005084193  0.021293537   0.05672958  0.002592639   0.04045477 > head(index(x)) [1] "2005-07-31" "2005-08-31" "2005-09-30" "2005-10-31" "2005-11-30" "2005-12-31" > temp=t(apply(-x, 1, rank, na.last = "keep")) > class(temp) [1] "matrix" > head(temp)            xly.adjusted xlp.adjusted xle.adjusted agg.adjusted ivv.adjusted 2005-07-31            3            4            1            5            2 2005-08-31            3            5            1            4            2 2005-09-30            5            4            1            3            2 2005-10-31            5            2            1            4            3 2005-11-30            5            3            1            4            2 2005-12-31            4            3            1            5            2 > head(rownames(temp)) [1] "2005-07-31" "2005-08-31" "2005-09-30" "2005-10-31" "2005-11-30" "2005-12-31" > y=as.xts(temp) > class(y) [1] "xts" "zoo" > head(y)            xly.adjusted xlp.adjusted xle.adjusted agg.adjusted ivv.adjusted 2005-07-31            3            4            1            5            2 2005-08-31            3            5            1            4            2 2005-09-30            5            4            1            3            2 2005-10-31            5            2            1            4            3 2005-11-30            5            3            1            4            2 2005-12-31            4            3            1            5            2 > head(index(y)) [1] "2005-07-31 bst" "2005-08-31 bst" "2005-09-30 bst" "2005-10-31 gmt" "2005-11-30 gmt" "2005-12-31 gmt" 

as.xts.matrix has dateformat argument defaults "posixct", assumes rownames of matrix datetimes. if want them dates, specify dateformat="date" in as.xts call.

y <- as.xts(temp, dateformat="date") 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -