Data Manipulation/Flow Control

R programming language resources Forums Data manipulation Data Manipulation/Flow Control

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #720
    slvrfox
    Member

    I’m new to R, but an experienced programmer.  I need to traverse a large number of conditional processing elements.  I can’t figure out how to exit an inner element and ‘fall through’ to the end of the outer element(s).

    As an example:

    while………..

    ifelse.(level2a)

    ifelse (level2b)

    ifelse (level2c)

    ifelse (level2d)

    endwhile

    I need to handle the situation where data fails the ifelse (Level2a), is processed at ifelse (level2b), then skips the remaining levels to the endwhile.  The reason is that my (large) dataset will require >100 conditionals to be evaluated if I have to goo through each one.  This is so simple to do in so many other languages, but I can’t figure out how to do it in R.

    Help, please!

    Don

    #722
    bryan
    Participant

    Don,

    Is the switch() function what you need?

    http://cran.r-project.org/doc/manuals/R-lang.html#switch

    #732
    slvrfox
    Member

    OK, I found the answer.   The Break and Next functions are exactly what I was looking for and hadn’t found.  Those, with Switch, will do the job nicely.  Thanks.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Scroll to top
Privacy Policy