Hi Peter,
Thank you so much.
Kind regards,
Lijun
-Original Message-
From: peter dalgaard
Sent: Friday, 21 February 2020 8:16 PM
To: Lijun Zhao
Cc: William Dunlap ; r-help@r-project.org
Subject: Re: [R] How to index the occasions in a vector repeatedly under
condition 1? if not, it
lap
Sent: Thursday, 20 February 2020 1:53 AM
To: Lijun Zhao
Cc: r-help@r-project.org
Subject: Re: [R] How to index the occasions in a vector repeatedly under
condition 1? if not, it will give a new index.
Use cumsum(logicalVector) to increment a counter at the TRUE positions in
logicalVector. . E
=15, it will
give a new index.
I want the output be like y.
y<-c(1,1,1,1,1,1,2,3,3)
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.z...@adelaide.edu.au<mailto:lijun.z...@adelaide.e
Dear All,
could you please help me how to get the output from the following example?
x<-c(543, 543, 543, 543, 551 , 551 ,1128 ,1197, 1197)
diff<-x-lag(x)
diff
[1] NA 0 0 0 8 0 577 69 0
how to index the occassions in x repeatedly if the diff>15? if not, it will
give a new in
4 matches
Mail list logo