8
library(mice)
md.pattern(dat1)
temp<-mice(dat1, m = 5, seed = 101)
dat1 <- complete(temp, 2)

Error in UseMethod("complete_") :
no applicable method for 'complete_' applied to an object of class "mids"

Hi, I'm trying to impute missing values using mice package. But I got the above error message. The first time I imputed missing data it worked, but when I tried again it didn't. I've tried a lot with different options (changing seed, deleting existing data or "temp" variable)

Sometimes it worked but other times it didn't. What is the problem and solution? Thanks in advance.

slamballais
  • 3,161
  • 3
  • 18
  • 29
Jonggi Choi
  • 81
  • 1
  • 3
  • 2
    This code should work. Please provide a complete example to reproduce the problem you describe. The error message indicates that R fails to find a `complete` method for the object type that is produced by `mice`. Are you sure that the `mice` package is loaded at all times? Does it change anything if you replace `complete` with `mice::complete`? – SimonG Nov 29 '16 at 14:55

3 Answers3

14

I think the problem here is that you should rather be using some other libraries in your program which have a function named "complete". Just typing "complete" in help menu gave me 2 other libraries (tidyr,RCurl) which have the function in the same name. As simon suggested, I tried using "mice::complete". It works for me.

Yaron
  • 10,166
  • 9
  • 45
  • 65
Eswar
  • 309
  • 1
  • 3
  • 10
1

Try this:

dat1<-mice::complete(temp,2)
Adrita Sharma
  • 21,581
  • 10
  • 69
  • 79
1

mice 3.7.5 redefines the complete() function as the S3 complete.mids() method for the generic tidyr::complete().

Assuming that mice is attached, you should no longer see no applicable method for 'complete_' applied to an object of class "mids".

Stef van Buuren
  • 348
  • 1
  • 10