amices / ggmice

Visualize incomplete and imputed data with the R package `ggmice`

Home Page:http://amices.org/ggmice

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

traceplot does not take 1 < number < all variables

gerkovink opened this issue · comments

library(mice)
library(ggmice)
imp <- mice(boys, m=2, maxit = 2, print=FALSE)
plot(imp, c("hgt", "wgt", "bmi"))

plot_trace(imp, c("hgt", "wgt", "bmi"))
#> Error in if (vrb %nin% varlist & vrb != "all") {: the condition has length > 1

Created on 2022-07-11 by the reprex package (v2.0.1)

I encountered the same problem. It could be fixed by simply changing:

  • if (vrb %nin% varlist & vrb != "all") { on line 26 to if (TRUE %in% (vrb %nin% varlist & vrb != "all")) { and

  • if (vrb == "all") { on line 29 to if (TRUE %in% (vrb == "all")) {.

Fixed in #80

library(mice)
#> 
#> Attaching package: 'mice'
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following objects are masked from 'package:base':
#> 
#>     cbind, rbind
library(ggmice)
#> 
#> Attaching package: 'ggmice'
#> The following objects are masked from 'package:mice':
#> 
#>     bwplot, densityplot, stripplot, xyplot
imp <- mice(boys, m=2, maxit = 2, print=FALSE)
plot(imp, c("hgt", "wgt", "bmi"))

plot_trace(imp, c("hgt", "wgt", "bmi"))

Created on 2023-06-27 with reprex v2.0.2