[R] Extracting data from a zoo by date

Gabor Grothendieck ggrothendieck at gmail.com
Tue Mar 6 23:45:34 CET 2012


On Tue, Mar 6, 2012 at 3:06 PM, Mago84 <davidquiasmo at gmail.com> wrote:
> Dear all,
>
> I know that it is a silly question, but I have a zoo object like this:
>
>                    valor1  valor2
> 01/02/08 36.7381 17.0097
> 01/03/08 36.9296 16.8331
> 01/04/08 35.6934 16.3539
> 01/07/08 35.3539 16.3791
> 01/08/08 36.3811 16.9340
> 01/09/08 37.9220 17.6655
>
> The name is nuevo.zoo and I need to extract the data for a giving day, for
> example for 01/03/08 and for the first column (36.9296). How can I do that?
>
> Sorry but I was looking for on the Internet, and I did not find the answer.
> I'm very new to the world of R project.
>

dt <- as.Date("01/03/08", "%m/%d/%y")

nuevo.zoo[dt]
# or
window(nuevo.zoo, dt)

See ?window.zoo

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list