R: simple and short if clauses for combind statements

Posted by jorgusch on Stack Overflow See other posts from Stack Overflow or by jorgusch
Published on 2010-03-18T21:04:06Z Indexed on 2010/03/18 21:21 UTC
Read the original article Hit count: 237

Filed under:
|

Hello,

TRUE/FALSE if clauses are easily and quickly done in R. However, if the argument gets more complex, it also gets ugly very soon.

For instance: I might want to execute different operations for a row(foo) dependent on the value in one cell (foo[1]). Let the intervals be 0:39 and 40:59 and 60:100

Something like does not exit:

(if foo[1] "in" 40:60){...

In fact, I only see ways of at least two if clauses and two else statements and the action for the first interval somewhere at the bottom of the code. With more intervals(or any other condition) it is getting more complex.

Is there a best practice (for this purpose or others) with a simple construction and nice design to read?

Thanks a lot!

© Stack Overflow or respective owner

Related posts about r

    Related posts about best-practice