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

How to do it…

To check if there is any missing value in any input vector in R, you could use the is.na() function. This is a very useful and intuitive function to check for missing values. Now, your objective is to check whether any missing value exists in the vectors x and y. You then need to print the location of the missing value. Here is the use of the if statement:

    if(any(is.na(x))){      cat("There are missing values in x at \n")      which(is.na(x))    }    if(any(is.na(y))){      cat("There are missing values in y at \n")      which(is.na(y))    }
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