Why doesn't this work? x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] x[as.Date('2001-01-05')] = 0 x I think this is especially bad because it doesn't cause an error. It lets you do something to x, but then you can't see x again to see what it did. [[alternative HTML version deleted]]
How exactly do you mean it doesn't work? Copied from my GUI:> x = zoo(1:5, as.Date('2001-01-01')+1:5) > x[as.Date('2001-01-05')]2001-01-05 4> x[as.Date('2001-01-05')] = 0 > x2001-01-02 2001-01-03 2001-01-04 2001-01-05 2001-01-06 1 2 3 0 5 (Those actually line up correctly on my machine..) Michael Weylandt On Mon, Aug 29, 2011 at 2:45 PM, Gene Leynes <gleynes+r@gmail.com> wrote:> Why doesn't this work? > > x = zoo(1:5, as.Date('2001-01-01')+1:5) > x[as.Date('2001-01-05')] > x[as.Date('2001-01-05')] = 0 > x > > > I think this is especially bad because it doesn't cause an error. It lets > you do something to x, but then you can't see x again to see what it did. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
On Aug 29, 2011, at 2:45 PM, Gene Leynes wrote:> Why doesn't this work? > > x = zoo(1:5, as.Date('2001-01-01')+1:5) > x[as.Date('2001-01-05')] > x[as.Date('2001-01-05')] = 0 > x > > > I think this is especially bad because it doesn't cause an error. > It lets > you do something to x, but then you can't see x again to see what it > did.It did exactly what I expected it to do. What was the "this" that you think was bad? I hope you are not asking that R ask users to confirm every assignment with a popup window. -- David Winsemius, MD West Hartford, CT
On Mon, Aug 29, 2011 at 2:45 PM, Gene Leynes <gleynes+r at gmail.com> wrote:> Why doesn't this work? > > x = zoo(1:5, as.Date('2001-01-01')+1:5) > x[as.Date('2001-01-05')] > x[as.Date('2001-01-05')] = 0 > x >Make sure you have the most recent version of zoo which is this:> packageVersion("zoo")[1] ?1.7.4? -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com