Jonathan has the correct answer for a vector, which you can apply to column a in the data frame using:
> dat<-data.frame(a=c(11,2,11,NA),b=c(1,1,1,1))
> dat$a[is.na(dat$a)] <- 1
To fully utilize the Deducer 'Recode Variables' dialog, which can perform much more complex re-writes, the following code is issued.
> library(Deducer)
> dat[c("a")] <- recode.variables(dat[c("a")] , "NA -> 1;")
source
share