damn, that's pretty clever. +1
thanks
On Thu, Feb 9, 2012 at 8:11 PM, ilai wrote:
> 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:
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 wrote:
> # I have a dataframe in the following form:
>
> track <- c(rep('A', 3), r
# I have a dataframe in the following form:
track <- c(rep('A', 3), rep('B', 4), rep('C', 4))
value <- c(0.15, 0.25, 0.35, 0.05, 0.99, 0.32, 0.13, 0.80, 0.75, 0.60, 0.44)
df <- data.frame(track=factor(track), value=value)
#> print(df)
#track value
#1 A 0.15
#2 A 0.25
#3 A 0.3
3 matches
Mail list logo