Hi all,

I'm trying to use kNNimpute in the imputation package to fill in missing
precipitation data for a data frame I have.


Example is:

okee:

Date                             rainfall
1997-05-01                    0
1997-05-02                    0
1997-05-03                    NA
1997-05-04                    0
1997-05-05                    0
.....................                    ..
2007-04-01                    NA
2007-04-02                    NA
2007-04-03                    NA
2007-04-04                    NA
2007-04-05                    0
...................                      ..
where there are large swatches (30 days) of data missing in the ten year
time series.

I tried newokee<-kNNImpute(okee, k=30, verbose = T) hoping it would impute
data for the rows with NA values according to weighted means of closest 30
non-NA neighbours and I got the following message back:

[1] "imputing on 270 missing values with matrix size 7304"
[1] "Computing distance matrix..."
[1] "Distance matrix complete"
[1] "Imputing row   70"
Error in which(missing.matrix[rowIndex, ]) : subscript out of bounds
In addition: Warning message:
In dist(x, upper = T) : NAs introduced by coercion


What syntax do I need to impute the precipitation data? Failing that, do
you have another recommendation of a method to use? Statistics is not my
strong point.

thank you for any help you are able to give,
Aimee.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to