Treatment of NaN values

Previously we saw that the is.na() function is able to detect both NA and NaN values. In the previous procedure, we removed both. If we analyze the original version of the data frame we can still see some NaN values:

> SampleData       name gender age right wrong1      Emma      F  24    80    202      Liam      M -19    NA    473    Olivia         32    75    254      Noah      M  15    60    405       Ava      F  18    45    556     Mason      M  21    54    467  Isabella      F  28   -19    858     Lucas      M  30    13    879    Sophia      F  26   NaN    3010   Elijah      M 100    98     211      Mia      F  22     5    9512   Oliver      M  NA   NaN    21

The presence of the NaN value is evident. What does this symbol represent? NaN is a symbol indicating that the result of a numeric operation was executed on invalid operands and therefore did not produce any result. Examples are the division by zero ...

Get Regression Analysis with R 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.