[R] Help with vector gymnastics

Gladwin, Philip philip.gladwin at citi.com
Wed Aug 22 16:41:29 CEST 2007


Hello,

What is the best way of solving this problem?

answer <- ifelse(tf=TRUE, i * 5, previous answer)
where as an initial condition 
tf[1] <- TRUE


For example if,
tf <- c(T,F,F,F,T,T,F)
over i = 1 to 7
then the output of the function will be
answer = 5 5 5 5 25 30 30 

Thank you.

Phil,



More information about the R-help mailing list