Re: [R] Coding a new variable based on criteria in a dataset

2010-12-22 Thread Hadley Wickham
>  It isn't quite convenient to read the data posted below into R > (if it was originally tab-separated, that formatting got lost) but > ddply from the plyr package is good for this: something like (untested) > >  d <- with(data,ddply(data,interaction(UniqueID,Reason), >                    function

Re: [R] Coding a new variable based on criteria in a dataset

2010-12-21 Thread Ben Bolker
RaoulD gmail.com> writes: > > > Hi, > > I'm a bit stuck and need some help with R code to code a variable F_R based > on a combination of conditions. > > The first condition would code F_R as "F" and would be based on the > min(Date) and Min(Time) for each combination of UniqueID & Reason. T

[R] Coding a new variable based on criteria in a dataset

2010-12-21 Thread RaoulD
Hi, I'm a bit stuck and need some help with R code to code a variable F_R based on a combination of conditions. The first condition would code F_R as "F" and would be based on the min(Date) and Min(Time) for each combination of UniqueID & Reason. The second condition would code the variable as