On May 13, 2014, at 7:49 AM, Baba Bukar wrote: > Dear all, > > I am new to R and have some problem computing transition probabilities. My > problem goes like this; > > data_set <- > c(2,0,45,6,78,3,0,2,6,0,5,8,0,2,8,9,12,212,22,4,1,0,3,5,88,5,69,12,4,0,0,0,0,4,87,6,99,104,22,7) > > observations greater than, say 3, is considered as useful (denoted as 1) > while less than 3 are not useful (denoted as 1). Am trying to calculate the > transition in these count data such as P_1,1=prob from useful to useful, > P_1,0=prob from useful to not useful, P_0,1=prob from not useful to useful > and P_0,0=prob from not useful to not useful. >
The rle function (run length encoding) might be helpful here: > rle( data_set >= 3 )$lengths [1] 2 4 2 1 1 2 2 6 2 7 4 7 > rle( data_set >= 3 )$values [1] FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE > Thank you much as you respond soonest > > Kind regards > Zakir > > [[alternative HTML version deleted]] This is a plain text mailing list. -- David Winsemius Alameda, CA, USA ______________________________________________ R-help@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.