R programming language resources › Forums › Data manipulation › Data Manipulation/Flow Control
Tagged: conditional execution, flow control, loops
- This topic has 2 replies, 2 voices, and was last updated 12 years, 7 months ago by
slvrfox.
- AuthorPosts
- September 25, 2012 at 6:41 pm #720
slvrfox
MemberI’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
September 25, 2012 at 7:22 pm #722bryan
ParticipantSeptember 25, 2012 at 11:01 pm #732slvrfox
MemberOK, 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.
- AuthorPosts
- You must be logged in to reply to this topic.