Skip to Main Content
Beyond Spreadsheets with R
book

Beyond Spreadsheets with R

by Jonathan Carroll
January 2019
Beginner to intermediate content levelBeginner to intermediate
352 pages
9h 8m
English
Manning Publications
Content preview from Beyond Spreadsheets with R

8 Doing things conditionally: Control structures

This chapter covers

  • Looping over sections of code
  • Conditionally evaluating code
  • Best practices to balance speed and readability

You saw in chapter 6 that you can conditionally select elements from data structures, but sometimes you only want to do (or not do) something based on some condition, or do something many times with slightly different conditions. There may be many steps you want to conditionally perform, so you need a way to only do things sometimes (or many times). You can use several approaches to do this in R, so let’s look at the most common and the most useful, as well as some other ways these tasks can be accomplished.

8.1 Looping

So far, you’ve evaluated code in a very linear ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Graphical Data Analysis with R

Graphical Data Analysis with R

Antony Unwin
Regression Analysis with R

Regression Analysis with R

Giuseppe Ciaburro, Pierre Paquay, Manoj Kumar, Shaikh Salamatullah
Advanced Machine Learning with R

Advanced Machine Learning with R

Cory Lesmeister, Dr. Sunil Kumar Chinnamgari

Publisher Resources

ISBN: 9781617294594Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentPurchase Link