Re: [R] xts error: number of items to replace is not a multiple of replacement length

2014-01-18 Thread Joshua Ulrich
This is particularly complicated and a bit of an edge case, so I wouldn't try too hard to understand what's going on, but I'll try to explain anyway. Your code creates two calls to the subset-replacement function (xts:::`[-.xts`). The first call replaces the value of Close in a temporary copy of

[R] xts error: number of items to replace is not a multiple of replacement length

2014-01-16 Thread ce
Dear all , I am getting this error while trying to change columns of an xts object with a date range as index. library(xts) Loading required package: zoo Attaching package: ‘zoo’ The following object is masked from ‘package:base’: as.Date, as.Date.numeric data(sample_matrix)

Re: [R] xts error: number of items to replace is not a multiple of replacement length

2014-01-16 Thread arun
Hi, Try: sample.xts[2007-01-02::2007-01-04,Close] -sample.xts[2007-01-02::2007-01-04,Close] +1 sample.xts[2007-01-02::2007-01-04] #   Open High  Low    Close #2007-01-02 50.03978 50.11778 49.95041 52.11778 #2007-01-03 50.23050 50.42188 50.23050 52.39767 #2007-01-04 50.42096

Re: [R] xts error: number of items to replace is not a multiple of replacement length

2014-01-16 Thread ce
Indeed it works ! Thanks a lot. But why? -Original Message- From: arun [smartpink...@yahoo.com] Date: 01/16/2014 08:44 PM To: r-help@r-project.org r-help@r-project.org Subject: Re: [R] xts error: number of items to replace is not a multiple of replacement length Hi, Try: