[R] converting blank cells to NAs

arun smartpink111 at yahoo.com
Tue Apr 16 15:38:03 CEST 2013

I am not sure about the problem.
If your non-numeric vector is like:

 vec1[vec1==""]<- NA
#[1] "a" "b" NA  "d" "e" NA  "f"

If this doesn't work, please provide an example vector.

>Thanks for the response.  That seems to do the trick as far replacing the empty 
cells with <NA>, however, the problem remains that the vector is 
not >numeric.  This was the reason I wanted to replace the empty cells 
with NAs in the first place.  Forcing the vector with as.numeric 
afterwards doesn't >seem to work either, I get nonsensical results.

More information about the R-help mailing list