Re: [R] Method Guidance

2022-01-14 Thread Leonard Mada via R-help
Dear Jeff, I am sending an updated version of the code. The initial version assumed that the time points correspond to an integer sequence. The code would fail for arbitrary times. The new code is robust. I still assume that the data is in column-format and that you want the time to the

Re: [R] Method Guidance

2022-01-13 Thread Bill Dunlap
Suppose your data were represented as parallel vectors "time" and "type", meaning that at time[i] a type[i] event occurred. You didn't say what you wanted if there were a run of "A" or "B". If you are looking for the time span between the last of a run of one sort of event and the first of a run

Re: [R] Method Guidance

2022-01-13 Thread Leonard Mada via R-help
Dear Jeff, My answer is a little bit late, but I hope it helps. jrdf = read.table(text="Time Event_AEvent_B Lag_B 1 1 10 2 0 11 3 0 00 4 1 00 5 0 11 6

Re: [R] Method Guidance

2022-01-12 Thread Avi Gross via R-help
, Jan 12, 2022 1:44 am Subject: Re: [R] Method Guidance Hi Jeff, A completely obscure question deserves a completely obscure answer: jrdf<-read.table(text="Time  Event_A    Event_B  Lag_B 1          1        1        0 2          0        1        1 3          0        0        0 4   

Re: [R] Method Guidance

2022-01-12 Thread Jeff Reichman
-project.org Subject: Re: [R] Method Guidance Hello, Here is a base R solution for what I understand of the question. It involves ave and cumsum. cumsum of the values of Event_A breaks Event_B in segments and ave applies a function to each segment. To find where are the times B, coerce to logical

Re: [R] Method Guidance

2022-01-12 Thread Rui Barradas
Hello, Here is a base R solution for what I understand of the question. It involves ave and cumsum. cumsum of the values of Event_A breaks Event_B in segments and ave applies a function to each segment. To find where are the times B, coerce to logical and have which() take care of it. Data in

Re: [R] Method Guidance

2022-01-11 Thread Jim Lemon
Hi Jeff, A completely obscure question deserves a completely obscure answer: jrdf<-read.table(text="Time Event_AEvent_B Lag_B 1 1 10 2 0 11 3 0 00 4 1 00 5 0 11 6

Re: [R] Method Guidance

2022-01-11 Thread Jeff Newmiller
1) Figure out how to post plain text please. What you saw is not what we see. 2) I see a "table" of input information but no specific expectation of what would come out of this hypothetical function. 3) Maybe you will find something relevant in this blog post:

[R] Method Guidance

2022-01-11 Thread Jeff Reichman
R-Help Forum Looking for a little guidance. Have an issue were I'm trying to determine the time between when Event A happened(In days) to when a subsequent Event B happens. For Example at Time 1 Evat A happens and subsequently Event B happens at the same day (0) and the next day (1) then Event