I have a table where there are "NA"s littered all over the place in one column in particular. I want to replace every instance of "NA" with something else -- say, the number 1.
How should I do that?
I have a table where there are "NA"s littered all over the place in one column in particular. I want to replace every instance of "NA" with something else -- say, the number 1.
How should I do that?
You can change the values with this SQL Statement.
Update TABLENAME
Set COLUMN_NAME = '1'
Where COLUMN_NAME = 'NA'
More info here
Jonathan has the right answer for a vector, which you can apply to column a in data frame dat using:
> dat<-data.frame(a=c(11,2,11,NA),b=c(1,1,1,1))
> dat$a[is.na(dat$a)] <- 1
For completeness using Deducer's 'Recode Variables' dialog, which can do much more complicated recodings, produces the following code.
> library(Deducer)
> dat[c("a")] <- recode.variables(dat[c("a")] , "NA -> 1;")