[R] Proba( Ut+2=1 / ((Ut+1==1) && (Ut==1))) ?
Dimitris Rizopoulos
dimitris.rizopoulos at med.kuleuven.ac.be
Mon Apr 25 18:22:37 CEST 2005
maybe something like this:
x <- sample(c(1, -1), 100, TRUE)
y <- rle(x)
##
ind1 <- y$length[y$value == 1]
sum(ind1[ind1 > 2] - 2)
ind2 <- y$length[y$value == -1]
##
sum(ind1[ind1 > 2] - 2)
could be helpful.
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
----- Original Message -----
From: "vincent" <vincent at 7d4.com>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, April 25, 2005 6:03 PM
Subject: [R] Proba( Ut+2=1 / ((Ut+1==1) && (Ut==1))) ?
> Dear all,
>
> First I apologize if my question is quite simple,
> but i'm very newbie with R.
>
> I have vectors of the form v = c(1,1,-1,-1,-1,1,1,1,1,-1,1)
> (longer than this one of course).
> The elements are only +1 or -1.
>
> I would like to calculate :
> - the frequencies of -1 occurences after 2 consecutives -1
> - the frequencies of +1 occurences after 2 consecutives +1
>
> It looks probably something like :
> Proba( Ut+2=1 / ((Ut+1==1) && (Ut==1)))
>
> could someone please give me a little hint about how
> i should/could begin to proceed ?
>
> Thanks
> (Thanks also to the R creators/contributors, this soft
> seems really great !)
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
More information about the R-help
mailing list