Replacing incorrect values

The next step will allow us to replace the incorrect value indicators. If we take a look at the data again, we will see that in the age column, the value -19 is displayed. That's obviously an incorrect value since for that variable, permissible values are greater than zero (this is an age):

24 -19 32 15 18 21 28 30 26 100 22 NA

We can replace this value with the missing value indicator, NA. To do this, we will write the following formula in the set suggestions:

IF($col<0, 'NA',$col)

A new step will be added to the Recipe panel immediately after the one created in the previous section. At the same time, we can see a preview of the changes made on the dataset. The incorrect value is no longer present; in its place, there is a further NA value.

The same result can be obtained by operating directly in the Recipe panel:

  1. Remember that to open the Recipe panel, you can just click on the icon (Recipe) at the top left of the Run Job button
  2. Click on the New Step button; the Transform Builder is opened
  3. In the Transformation drop-down menu, select Apply formula in the list of available transforms
  4. Specify the Columns (age)
  5. Edit the formula required in the Formula box
  6. Click on the Add button
  7. A new step is added to the Recipe panel

In the following screenshot, we can see the Transform Builder:

The result obtained is identical to the result we obtained by writing the formula in the set suggestions; even in this case, a negative value will no longer be present in the age column.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.12.183