Skip to content
David Lawrence Miller edited this page Oct 3, 2013 · 2 revisions

When attempting to calculate the variance using dsm.var.prop or dsm.var.gam you may come up against the following error:

Error in if (x0[i] == 0) 1 else x0[i] :
  missing value where TRUE/FALSE needed

This occurs because the prediction data set you're using has NA values for one or more covariate(s) in one or more cells. Removing those prediction cells will remove this problem.

The following code will remove any rows of the variable pred that have NA values. One should be careful to ensure that pred only has the variables that are being used for prediction in it and that extra rows are not removed by NAs in columns that are not used in prediction.

pred <- pred[apply(pred,1,function(x){!any(is.na(x))}),]

This is a temporary work-around and will be fixed in the next version of dsm.

Clone this wiki locally