Dear list,
Is there anyway i can make the following formula short
by r-programming?
CYCLE.n<-c(NA,
WET[1]*DRY[1],
WET[1]*DRY[2]+WET[2]*DRY[1],
WET[1]*DRY[3]+WET[2]*DRY[2]+WET[3]*DRY[1],
WET[1]*DRY[4]+WET[2]*DRY[3]+WET[3]*DRY[2]+WET[4]*DRY[1],
WET[1]*DRY[5]+WET[2]*DRY[4]+WET[3]*DRY[3]+WET[4]*DRY[2
Mohammad Ehsanul Karim <[EMAIL PROTECTED]> writes:
> Dear list,
>
> Is there anyway i can make the following formula short
> by r-programming?
>
> CYCLE.n<-c(NA,
> WET[1]*DRY[1],
> WET[1]*DRY[2]+WET[2]*DRY[1],
> WET[1]*DRY[3]+WET[2]*DRY[2]+WET[3]*DRY[1],
As far as I can see:
z <- toeplit
Try:
> DRY<-c(2,5,3,7,11)
> WET<-(1:5)*10
> print(filter(c(rep(0,length(WET)),DRY),WET))
Time Series:
Start = 1
End = 10
Frequency = 1
[1] NA NA 0 20 90 190 360 640 NA NA
> CYCLE.n<-c(NA,
> WET[1]*DRY[1],
> WET[1]*DRY[2]+WET[2]*DRY[1],
> WET[1]*DRY[3]+WET[2]*DRY[2]+WET[3]*DRY[1],
In addition to Peter's suggestion of converting
to a matrix operation, here is a simple solution
using naive R programming.
Using the 7th element of CYCLE.n as an example:
replace this:
WET[1]*DRY[6]+WET[2]*DRY[5]+WET[3]*DRY[4]+WET[4]*DRY[3]+WET[5]*DRY[2]+WET[6]*DRY[1]
with this:
sum(WE
Dear List,
Suppose we have a variable K.JUN defined as (with
1=wet, 0=dry):
K.JUN1984 = c(1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
K.JUN1985 = c(0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1)
K.JUN1986 =
Dear List,
Is there any way we can make the following formula any
shorter by means of R programming:
# Transition Probabilities observed for 19 years
p01<-0.4052863; p11<-0.7309942
# Now we try to find expected probabilities
# for number of wet days in a week
# as defined by Gabriel, Neumann (1
On 6/24/05, Mohammad Ehsanul Karim <[EMAIL PROTECTED]> wrote:
> Dear List,
>
> Suppose we have a variable K.JUN defined as (with
> 1=wet, 0=dry):
>
> K.JUN1984 = c(1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1,
> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
> K.JUN1985 = c(0, 1, 0, 1, 0, 0, 1, 0, 0
AIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mohammad Ehsanul
Karim
Sent: Friday, June 24, 2005 5:16 AM
To: r help
Subject: [R] r programming help III
Dear List,
Is there any way we can make the following formula any shorter by means of R
programming:
# Transition Probabilities observed
gt; (703) 676-4192 "> \
> [EMAIL PROTECTED] `\
>
>
>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Mohammad Ehsanul
> Karim
> Sent: Friday, June 24, 2005