Re: [R] alternative for multiple if_else statements

2018-02-26 Thread Kevin Wamae
S Ellison > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Kevin > Wamae > Sent: 21 February 2018 20:34 > To: R-help@r-project.org > Subject: [R] alternative for multiple if_else statements >

Re: [R] alternative for multiple if_else statements

2018-02-26 Thread S Ellison
t: 21 February 2018 20:34 > To: R-help@r-project.org > Subject: [R] alternative for multiple if_else statements > > Hi, I am having trouble trying to figure out why if_else is behaving the way > it is, > it may be my code or the way the data is structured. > > Below is a sn

Re: [R] alternative for multiple if_else statements

2018-02-22 Thread Kevin Wamae
15:16 To: Kevin Wamae <kwa...@kemri-wellcome.org> Cc: "R-help@r-project.org" <R-help@r-project.org> Subject: Re: [R] alternative for multiple if_else statements Hi Kevin, I ran the code on the full data set and was able to reproduce the problem that you are facing. My guess is th

Re: [R] alternative for multiple if_else statements

2018-02-22 Thread Kevin Wamae
Dear Ista, thank you. Let me see how best I can implement this. Regards -- Kevin Wamae On 22/02/2018, 16:58, "Ista Zahn" wrote: I don't fully understand the logic you are trying to implement, but something along the lines of foo <-

Re: [R] alternative for multiple if_else statements

2018-02-22 Thread Ista Zahn
I don't fully understand the logic you are trying to implement, but something along the lines of foo <- cut(trialData$date, breaks = as.Date(c("2007-01-01", "2008-05-01", "2009-04-01",

Re: [R] alternative for multiple if_else statements

2018-02-22 Thread Eric Berger
gt;= trialData$date[trialData$survey_start > == "Y" & trialData$year == 2013 & trialData$site == "site_1"][1] & > trialData$date < trialData$date[trialData$month == 4 & trialData$year == > 2014 & trialData$site == "site_1"][1]] <- &quo

Re: [R] alternative for multiple if_else statements

2018-02-22 Thread Eric Berger
Hi, 1. I think the reason that the different ordering leads to different results is because of the following: date[ some condition is true ][1] will give you an NA if there are no rows where 'some condition holds'. In the code that 'works' you don't have such a situation, but in the

[R] alternative for multiple if_else statements

2018-02-21 Thread Kevin Wamae
Hi, I am having trouble trying to figure out why if_else is behaving the way it is, it may be my code or the way the data is structured. Below is a snapshot of a database am working on and it represents a longitudinal survey of study participants in a trial with weekly follow up. The variable