Skip to Content
Modern R Programming Cookbook
book

Modern R Programming Cookbook

by Jaynal Abedin
October 2017
Beginner to intermediate
236 pages
7h 38m
English
Packt Publishing
Content preview from Modern R Programming Cookbook

Getting ready

Unlike the ifelse function, if…else works for conditioning on a scalar-valued input and output. The ifelse function takes the input as a vector and produces a vector output with the same length as that of the input. However, if…else takes only a scalar-valued input and it only generates TRUE or FALSE and then executes the body of task that you define. Let’s assume you have a number stored in the variable a and you want to test whether the given number is odd or even. In this recipe, you will write R code to test the a variable. The value of a could be any arbitrary integer number.

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

R Cookbook, 2nd Edition

R Cookbook, 2nd Edition

JD Long, Paul Teetor

Publisher Resources

ISBN: 9781787129054Supplemental Content