Skip to content
Back to formatted view

Raw Message

Message-ID: <AANLkTi=KmxyLVVpmvA1cTt7_iB3YfpO9EMO6TF55C6_v@mail.gmail.com>
Date: 2011-01-24T10:54:38Z
From: Blair Sutton
Subject: how to slice a zoo object
In-Reply-To: <AANLkTikp84=rMNWmU9Hx_jByrr50Fc-HoF_-YGSxmeUx@mail.gmail.com>

I've solved my own problem using ZOO_OBJ[,"COL2", "COL5"]. The trick
was preceding the list of names with a comma as described in the
standard ts document.

On Mon, Jan 24, 2011 at 9:51 AM, Blair Sutton <blairuk at gmail.com> wrote:
> Hi
>
> Would anyone have any pointers on how to slice up a large zoo table. I
> have the following structure: -
>
>> str(ZOO_OBJ)
> ?zoo [1:632, 1:83] 30.4 30.4 30.4 30.4 30.3 ...
> ?- attr(*, "dimnames")=List of 2
> ??..$ : NULL
> ??..$ : chr [1:83] "COL1" "COL2" "COL3" "COL4" ...
> ?- attr(*, "index")= POSIXct[1:632], format: "2009-05-01 01:00:00"
> "2009-05-02 01:00:00" ...
>
> and I would just like to take only arbitrary columns, i.e. another zoo
> object with only the columns "COL2", "COL5", etc..
>
> I've tried various syntactical combinations such as those for
> data.frames and also tried manipulating the coredata(). What would be
> nice would be the ability to do this by column names and not their
> indexes.
>
> Any help appreciated and thanks in advance,
> Blair
>