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:
- Remember that to open the Recipe panel, you can just click on the icon (Recipe) at the top left of the Run Job button
- Click on the New Step button; the Transform Builder is opened
- In the Transformation drop-down menu, select Apply formula in the list of available transforms
- Specify the Columns (age)
- Edit the formula required in the Formula box
- Click on the Add button
- 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.