© Margot Tollefson 2019
Margot TollefsonR Quick Syntax Referencehttps://doi.org/10.1007/978-1-4842-4405-0_17

17. Tricks of the Trade

Margot Tollefson1 
(1)
Stratford, IA, USA
 

This book would not be complete without advice on some tricky parts of R. When it seems that everything is set up right, but things still do not do what you expect and you do not know why, this chapter can help. This chapter also describes some not-so-obvious parts of R.

Value Substitution: NA, NaN, Inf, and –Inf

This section has to do with missing data (NA) or illegal elements (NaN, Inf, or –Inf). Say you want to substitute a value, for example 0, for missing values. The intuitive approach would be to enter something like the following:
mat[ mat==NA ] = 0
This does not work. What ...

Get R Quick Syntax Reference: A Pocket Guide to the Language, APIs and Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.