Replace incorrect value

The next step will allow us to replace the incorrect value indicators. If we give a look at the data again, we can see that in the right column the value -19 is displayed, which is obviously an incorrect value since for that variable, permissible values are between 0 and 100 (this is a percentage):

> SampleData$right [1]  80  NA  75  60  45  54 -19  13 NaN  98   5 NaN

We can replace that value with the missing value indicator that is said to be NA. To do this we will write:

SampleData$right[SampleData$right == -19 ] <- NA

Let's try to see this variable again:

> SampleData$right [1]  80  NA  75  60  45  54  NA  13 NaN  98   5 NaN

The incorrect value is no longer present, in its place there is a further NA value.

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.