[R] Fwd: time series patterns

Raphael Fraser raphael.fraser at gmail.com
Sat Jul 1 00:00:00 CEST 2006


---------- Forwarded message ----------
From: Alexander Nervedi <alexnerdy at hotmail.com>
Date: Jun 30, 2006 4:56 PM
Subject: time series patterns
To: raphael.fraser at gmail.com


Hi all.

I have a factor variable distributed over time. I am looking for an elegant
way to code duration of a state. Suppose,

>rainfall.shocks <- factor(sample(c(1,2,3), size = 15, replace = TRUE, prob
>= unit.p),
+                  label = c("Drought", "Normal", "High"))
>
>rainfall.shocks
[1] Normal  High    High    Drought Normal  Normal  High    Normal  Drought
[10] Normal  Drought Normal  Normal  Normal  Normal


So capture the duration of say drought, I'd need a variable that is able to
keep track of rainfall.shocks as well as its past values. I was wondering if
there is any obvious way to do this. the Drought variable in this case would
have values

0 0 0 1 0 0 0 0 1 0 1 0 0 0 0

many thanks for the suggestions you are likely to make.

Alexander Nervedi

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



More information about the R-help mailing list