lundi 30 mars 2020

How to create a binary value to capture null values in R?

Here is a simplified version of my current dataset:

v1    v2     v3
null  b      c
a     b      c
a     null   c 

I want to create a new column called 'v4' that would be a 1, ONLY if v1 is null, and 0, if v1 was not null.

The desired output would look like this

v1    v2     v3 v4
null  b      c  1
a     b      c  0
a     null   c  0

Any help with this would be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire