[R] zoo objects and "c"

Gabor Grothendieck ggrothendieck at gmail.com
Mon Jul 26 21:07:35 CEST 2010


On Mon, Jul 26, 2010 at 2:24 PM, Erin Hodgess <erinm.hodgess at gmail.com> wrote:
> Whoops...sorry about that.  Here we go:
>
>> dput(xgh)
> structure(c(5, 6, 1, 5, 0, 0, 13, 9, 6, 4, 6, 0, 0, 9, 15, 10,
> 5, 6, 0, 0, 0, 12, 8, 3, 6, 0), index = structure(c(14775, 14776,
> 14777, 14778, 14779, 14780, 14781, 14782, 14783, 14784, 14785,
> 14786, 14787, 14788, 14789, 14790, 14791, 14792, 14793, 14794,
> 14795, 14796, 14797, 14798, 14799, 14800), class = "Date"), class = "zoo")
>> dput(xs)
> structure(c(14775, 14776, 14777, 14778, 14779, 14780, 14781,
> 14782, 14783, 14784, 14785, 14786, 14787, 14788, 14789, 14790,
> 14791, 14792, 14793, 14794, 14795, 14796, 14797, 14798, 14799,
> 14800, 14801, 14802, 14803, 14804, 14805), class = "Date")
>> zoo(c(xgh,-0.7,3.6,3.7,3.4,3.2),order=xs)
> Error in rbind.zoo(...) : indexes overlap
>>
>
>
> I just tried this:
>
> zoo(c(as.numeric(xgh),-0.7,3.6,3.7,3.4,3.2),order=xs)
>
> and it does work.  However, I'm not sure if that's the right way to go.
>

It should be written like this:

   zoo(c(coredata(xgh), -0.7, 3.6, 3.7, 3.4, 3.2), xs)



More information about the R-help mailing list