Skip to content

Apply pmax to dataframe with different args based on dataframe factor

3 messages · ilai, Idris Raja

#
Your attempt was just overly complicated. All you needed was

threshold <- c( .2 , .4 , .5 )[ df$track ]
df$value <- pmax(threshold, df$value)
df # desired outcome

Cheers
On Thu, Feb 9, 2012 at 3:56 PM, Idris Raja <idris.raja at gmail.com> wrote: