Re: [R] alternative for multiple if_else statements

2018-02-26 Thread Kevin Wamae
son > -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 > > Hi, I

Re: [R] alternative for multiple if_else statements

2018-02-26 Thread S Ellison
Wamae > Sent: 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. > >

Re: [R] alternative for multiple if_else statements

2018-02-22 Thread Kevin Wamae
elp@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 that you have an error in your intuition and/or logic, and that this relates to the use of the

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 <- cut(trialData$date,

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", "2010-05-01"

Re: [R] alternative for multiple if_else statements

2018-02-22 Thread Eric Berger
y_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]] <- "survey_2013" > > > &

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 cod

[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 "