[R] filling blanks with NA
K. Elo
maillists at nic.fi
Wed Jan 21 16:35:14 CET 2009
Hi,
kayj wrote:
> Hi,
>
> I do have a data set with some missing values that appear as blanks. I want
> to fill these blanks with an NA. How can this be done? Thanks for your help
Something like this?
> my.data<-data.frame("var"=c(1,2,5,"",66,4,3,"",67,5,3,2,1,4,32,56,23),
stringsAsFactors=F)
> my.data$var
[1] "1" "2" "5" "" "66" "4" "3" "" "67" "5" "3" "2" "1"
"4" "32" "56" "23"
> my.data$var[ my.data$var=="" ] <-NA
> my.data$var
[1] "1" "2" "5" NA "66" "4" "3" NA "67" "5" "3" "2" "1"
"4" "32" "56" "23"
Kind regards,
Kimmo
More information about the R-help
mailing list