Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tibble 3.0.0 (on CRAN) breaks a number of glance methods #823

Closed
IndrajeetPatil opened this issue Mar 6, 2020 · 7 comments
Closed

tibble 3.0.0 (on CRAN) breaks a number of glance methods #823

IndrajeetPatil opened this issue Mar 6, 2020 · 7 comments

Comments

@IndrajeetPatil
Copy link
Contributor

IndrajeetPatil commented Mar 6, 2020

I think this has to do with tibble 3.0.0:

# setup
set.seed(123)
library(robustbase)
library(broom)

# dataframe
data(coleman)
clotting <- data.frame(
  u = c(5, 10, 15, 20, 30, 40, 60, 80, 100),
  lot1 = c(118, 58, 42, 35, 27, 25, 21, 19, 18),
  lot2 = c(69, 35, 26, 21, 18, 16, 13, 12, 12)
)


mod1 <- robustbase::glmrob(
      formula = lot1 ~ log(u),
      data = clotting,
      family = Gamma
    )

mod2 <- robustbase::lmrob(formula = Y ~ ., data = coleman)

glance(mod1)
#> Error: Input must be a vector, not NULL.
glance(mod2)
#> # A tibble: 1 x 3
#>   r.squared sigma df.residual
#>       <dbl> <dbl>       <int>
#> 1     0.981  1.13          14
@IndrajeetPatil

This comment has been minimized.

@IndrajeetPatil IndrajeetPatil changed the title glance method fails for glmrob objects tibble 3.0.0 (on CRAN) breaks a number of glance methods Mar 30, 2020
@IndrajeetPatil
Copy link
Contributor Author

Another example with bracl

# setup
set.seed(123)
library(brglm2)
data("stemcell")

# bias reduction for adjacent category logit models
# for ordinal responses using the Poisson trick
fit_bracl <-
  brglm2::bracl(
    formula = research ~ as.numeric(religion) + gender,
    weights = frequency,
    data = stemcell,
    type = "ML"
  )

# glance
broom::glance(fit_bracl)
#> Error: Input must be a vector, not NULL.
#> Backtrace:
#>      x
#>   1. +-base::tryCatch(...)
#>   2. | \-base:::tryCatchList(expr, classes, parentenv, handlers)
#>   3. |   +-base:::tryCatchOne(...)
#>   4. |   | \-base:::doTryCatch(return(expr), name, parentenv, handler)
#>   5. |   \-base:::tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#>   6. |     \-base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>   7. |       \-base:::doTryCatch(return(expr), name, parentenv, handler)
#>   8. +-base::withCallingHandlers(...)
#>   9. +-base::saveRDS(...)
#>  10. +-base::do.call(...)
#>  11. +-(function (what, args, quote = FALSE, envir = parent.frame()) ...
#>  12. +-(function (input, opts) ...
#>  13. | \-rmarkdown::render(input, quiet = TRUE, envir = globalenv(), encoding = "UTF-8")
#>  14. |   \-knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
#>  15. |     \-knitr:::process_file(text, output)
#>  16. |       +-base::withCallingHandlers(...)
#>  17. |       +-knitr:::process_group(group)
#>  18. |       \-knitr:::process_group.block(group)
#>  19. |         \-knitr:::call_block(x)
#>  20. |           \-knitr:::block_exec(params)
#>  21. |             +-knitr:::in_dir(...)
#>  22. |             \-knitr:::evaluate(...)
#>  23. |               \-evaluate::evaluate(...)
#>  24. |                 \-evaluate:::evaluate_call(...)
#>  25. |                   +-evaluate:::handle(...)
#>  26. |                   | \-base::try(f, silent = TRUE)
#>  27. |                   |   \-base::tryCatch(...)
#>  28. |                   |     \-base:::tryCatchList(expr, classes, parentenv, handlers)
#>  29. |                   |       \-base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>  30. |                   |         \-base:::doTryCatch(return(expr), name, parentenv, handler)
#>  31. |                   +-base::withCallingHandlers(...)
#>  32. |                   +-base::withVisible(value_fun(ev$value, ev$visible))
#>  33. |                   \-knitr:::value_fun(ev$value, ev$visible)
#>  34. |                     \-knitr:::fun(x, options = options)
#>  35. |                       +-base::withVisible(knit_print(x, ...))
#>  36. |                       +-knitr::knit_print(x, ...)
#>  37. |                       \-rmarkdown:::knit_print.data.frame(x, ...)
#>  38. |                         +-context$df_print(x)
#>  39. |                         \-tibble:::print.tbl(x)
#>  40. |                           +-cli::cat_line(format(x, ..., n = n, width = width, n_extra = n_extra))
#>  41. |                           | \-base::paste0(..., collapse = "\n")
#>  42. |                           +-base::format(x, ..., n = n, width = width, n_extra = n_extra)
#>  43. |                           \-tibble:::format.tbl(x, ..., n = n, width = width, n_extra = n_extra)
#>  44. |                             \-tibble::trunc_mat(x, n = n, width = width, n_extra = n_extra)
#>  45. |                               +-base::as.data.frame(head(x, n))
#>  46. |                               +-utils::head(x, n)
#>  47. |                               \-utils:::head.data.frame(x, n)
#>  48. |                                 +-base::do.call("[", args)
#>  49. |                                 +-x[1L, , drop = FALSE]
#>  50. |                                 \-tibble:::`[.tbl_df`(x, 1L, , drop = FALSE)
#>  51. |                                   \-tibble:::tbl_subset_row(xo, i = i, i_arg)
#>  52. |                                     \-base::lapply(unclass(x), vec_slice, i = i)
#>  53. |                                       \-vctrs:::FUN(X[[i]], ...)
#>  54. \-vctrs:::stop_scalar_type(.Primitive("quote")(NULL), "")
#>  55.   \-vctrs:::stop_vctrs(msg, "vctrs_error_scalar_type", actual = x)

@alexpghayes
Copy link
Collaborator

At the moment I'm a bit overwhelmed. I'll try to get to this when I can, but my priority at the moment is to get the CRAN version of broom to be happy with tibble 3.0.0. It may be a moment.

@IndrajeetPatil
Copy link
Contributor Author

@simonpcouch Can this be also resolved before the 0.7.0 release?

@simonpcouch
Copy link
Collaborator

Moving over to this issue in the next couple days! Thanks for checking in!

@simonpcouch
Copy link
Collaborator

Seems like the issue here is that tibble will now error, rather than returning a 0-row tibble / tibble with NULLs, when given NULL as a column entry. When a fit is rank-deficient(?), many of the entries dropped into glance.*() tibbles are NULL. Working on a helper right now that, given a named list (supplied in ...), will return a 1-row tibble with appropriate NA types switched out for NULL values.

simonpcouch added a commit that referenced this issue Jun 3, 2020
@github-actions
Copy link

github-actions bot commented Mar 8, 2021

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants