[R] setting up zoo objects from a data frame

From: Erin Hodgess <erinm.hodgess_at_gmail.com>
Date: Tue, 08 Jun 2010 09:52:10 -0500


Dear R People:

I have the following data frame:

> str(dog.df)

'data.frame': 7 obs. of 2 variables:
 $ V1: Factor w/ 3 levels "1/1/2000","1/2/2000",..: 1 1 1 2 2 3 3  $ V2: Factor w/ 3 levels "cat","dog","tree": 2 1 3 1 3 2 3
> dog.df

        V1 V2

1 1/1/2000  dog
2 1/1/2000  cat
3 1/1/2000 tree
4 1/2/2000  cat
5 1/2/2000 tree
6 1/3/2000  dog
7 1/3/2000 tree

>

I would like to set up 3 time series; one for dog, one for cat, one for tree, such that each runs from 1/1/2000 to 1/3/2000, with 0 if there is no entry for the day.

So for instance, I would have:

dog.zoo

1/1/2000 1
1/2/2000 0
1/3/2000 1

Any help would be much appreciated.

Thanks in advance,
Sincerely,
Erin

-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodgess_at_gmail.com

______________________________________________
R-help_at_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.
Received on Tue 08 Jun 2010 - 14:54:36 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 08 Jun 2010 - 15:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive