dotwhisker icon indicating copy to clipboard operation
dotwhisker copied to clipboard

Error when passing list to `secretweapon()`: `argument "margins" is missing, with no default`

Open davidskalinder opened this issue 7 months ago • 0 comments

I'm new to dotwhisker, so I hope I'm not making some obvious mistake here, but I'm getting this error when I pass a list of models to secretweapon(). Passing the same models as a pre-tidied data frame works fine.

It looks like the margins functionality was recently changed, so I'm guessing something was fixed for one type of input but not the other?

Here's a reprex showing that the plot works when the models are passed as a data frame but not when they're passed as a list. Note that the error is thrown even when margins is explicitly specified; I assume that means something is going on with an underlying call (probably to dwplot()?).

m1 <- lm(mpg ~ wt + cyl + disp + gear, data = mtcars)
m2 <- update(m1, . ~ . + hp) # add another predictor
m3 <- update(m2, . ~ . + am) # and another
ms_df <-
  list(m1 = m1, m2 = m2, m3 = m3) |>
  purrr::map(broom::tidy) |>
  purrr::list_rbind(names_to = "model")
dotwhisker::secret_weapon(ms_df, var = "wt")

dotwhisker::secret_weapon(list(m1, m2, m3), var = "wt", margins = FALSE)
#> Error in `purrr::map()`:
#> ℹ In index: 1.
#> ℹ With name: Model 1.
#> Caused by error in `.f()`:
#> ! argument "margins" is missing, with no default

Created on 2025-05-23 with reprex v2.1.1

Of course let me know if I can provide any more info!

davidskalinder avatar May 23 '25 23:05 davidskalinder