2
Good evening colleagues:
I have a numeric variable:
cv1[1:10] [1] 0 0 108919 4152 317 334403 0 35092 12762 NA
I want to create the variable cv2, replacing the absolute values of zero (0) with "NA". Using the "gsub" function it replaces ALL zero numerals, including the numbers that have zero in the middle of them: (108919, 334403, 35092)
cv2=gsub("0",NA,cv1)
cv2[1:10] [1] NA NA "4152" "317" NA NA "12762" NA
How could ma change only absolute values from zero to NA.Can anyone help me?