[R-sig-Geo] Imputation of missing values

John Tomkinson gga01jet at yahoo.co.uk
Wed Jul 10 12:26:56 CEST 2013


Hi all,

I would like to impute missing values in a data set based on the distribution of the other values of the variable.

Imagine that 30 % of the values = 1, 20 % = 2 and 50 % = 3, in effect I'd like to do the following :

df$var[df$var==NA]<-1 # for 30 % of the NA occurrences #
df$var[df$var==NA]<-2 # for 20 % of the NA occurrences #
df$var[df$var==NA]<-3 # for 50 % of the NA occurrences #

Can anybody help ?

John




More information about the R-sig-Geo mailing list