Skip to main content

Flow Control

  • Chapter
  • First Online:
R 4 Quick Syntax Reference
  • 941 Accesses

Abstract

Flow control statements are used to repeat a series of tasks a number of times or to direct flow based on a logical object. For persons who came into programming in the age of FORTRAN and BASIC, using loops is very comfortable. (In looping, either an index is used to apply a group of expressions to each element of an object or a group of expressions is repeated until a condition is met.) In R, the better choice, if possible, is to select multiple indices of an object(s) (for an object(s) with dimensions) and to operate of the selection, instead of looping through each individual index. For many of the tasks that can be done by flow control statements, using indices is faster than looping.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+
from €37.37 /Month
  • Starting from 10 chapters or articles per month
  • Access and download chapters and articles from more than 300k books and 2,500 journals
  • Cancel anytime
View plans

Buy Now

eBook
EUR 17.99
Price includes VAT (Netherlands)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
EUR 59.94
Price includes VAT (Netherlands)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2022 The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Tollefson, M. (2022). Flow Control. In: R 4 Quick Syntax Reference. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-7924-3_12

Download citation

Publish with us

Policies and ethics