[R] Package mice: Error in if (meth[j] != "") { : argument is of length zero

Joshua Wiley jwiley.psych at gmail.com
Sun Apr 10 08:26:24 CEST 2011

On Fri, Apr 8, 2011 at 2:56 PM, Rita Carreira <ritacarreira at hotmail.com> wrote:
> Dear R users,
> I am using package mice and I am getting the error "
> Error in if (meth[j] != "") { : argument is of length zero." I have tried using several different versions of R (even the one that will be coming out this month) to no avail. I am using RStudio as my interface with R. Also note that I had run this a couple of days ago and it was working fine; I can't, however, remember the version of R that I was using but it was either R-2.11.1 or R-2.12.1. Please find below my code and error. Any thoughts or ideas?
>> library(mice)
> # setting up the default settings for the imputation
> ini <- mice(NewPrimal,

Without NewPrimal, we cannot reproduce what you are seeing (this is
where small sample datasets are helpful).

>            seed = 52275,
>            method = "norm",
>            maxit=0,
>            pred = quickpred(NewPrimal,
>                   mincor = 0.25,
>                   minpuc = 0.95,
>                   include = c("D1", "D2", "D3",
>                               "Qtr1", "Qtr2", "Qtr3",
>                               "Feb", "Mar", "Apr", "May", "Jun", "Jul",
>                               "Aug", "Sep", "Oct", "Nov", "Dec"),
>                   exclude = c("ActualWeekEndingDate", "Date", "Year")),
>                   print=FALSE)
> Error in if (meth[j] != "") { : argument is of length zero

You can get more details right after the error by typing:


a quick grep of the mice code suggests the error forcing an exit may
occur around line 155.  You might be able to do something like:


and then add a browser() call in somewhere before line 155 and then
poke around to get a better sense of what is going on.



> Thank you so very much!
> Rita
> ________________________________________
> "If you think education is expensive, try ignorance"--Derek Bok
>        [[alternative HTML version deleted]]
> ______________________________________________
> R-help at 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.

Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles

More information about the R-help mailing list