[R] How to index the occasions in a vector repeatedly under condition 1? if not, it will give a new index.

Lijun Zhao ||jun@zh@o @end|ng |rom @de|@|de@edu@@u
Wed Feb 19 07:51:53 CET 2020

Dear all,
Could you please help me how to get the output as I described in the following example?

x<-c(543,  543,  543,  543,  551 , 551 ,1128 ,1197, 1197)
[1]  NA   0   0   0   8   0 577  69   0

How to index the occasions in x repeatedly if the diff<15? if diff>=15, it will give a new index.
I want the output be like y.


Thank you so much,

Lijun Zhao (PhD Candidate)
Nutrition and Metabolism
Level 7 SAHMRI
North Terrace
Adelaide 5005
Ph    : +61 8 8128 4898
e-mail: lijun.zhao using adelaide.edu.au<mailto:lijun.zhao using adelaide.edu.au> or lijun.zhao using sahmri.com<mailto:lijun.zhao using sahmri.com>

	[[alternative HTML version deleted]]

More information about the R-help mailing list