Re: [R] flagging values without a loop

2012-06-07 Thread andrija djurovic
Hi. Yes it is possible. Here is one approach: DF <- read.table(textConnection(" Unit DayHour Price Flag afd11/2/20031 1 N afd11/2/20031 2 N afd11/2/20031 3 N afd11/2/20031 4 Y dcf11/2/2003

Re: [R] flagging values without a loop

2012-06-07 Thread R. Michael Weylandt
In two steps, you could use ave() to split by hour and find the maximum of price and then use an ifelse clause on the resulting vector to see when that actually equals the given price and assign "Y"/"N" appropriately, I'll leave the implementation as an exercise to the reader :-) Best, Michael O