[R] setting up zoo objects from a data frame

Erin Hodgess erinm.hodgess at gmail.com
Tue Jun 8 16:52:10 CEST 2010


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



More information about the R-help mailing list