emitanaka / deggust

An R-package to visualise edibble designs as ggplot graphics
https://deggust.emitanaka.org
12 stars 2 forks source link

autoplot throws error #13

Closed myaseen208 closed 1 year ago

myaseen208 commented 1 year ago

The autoplot function not rendering the plot and throws the following error:

library(edibble)
library(deggust)
#> Loading required package: ggplot2

CRD1 <- 
  takeout(
    recipe = menu_crd(
                        t    = 5
                      , n    = 30
                      , r    = 
                      , seed = 12345
                      )
  , show   = TRUE
    )
CRD1
#> design("Completely Randomised Design") %>%
#>   set_units(unit = 30) %>%
#>   set_trts(trt = 5) %>%
#>   allot_trts(trt ~ unit) %>%
#>   assign_trts("random", seed = 12345) %>%
#>   serve_table() 
#> 
#> # Completely Randomised Design 
#> # An edibble: 30 x 2
#>          unit      trt
#>  * <unit(30)> <trt(5)>
#>  1     unit1      trt4
#>  2     unit2      trt2
#>  3     unit3      trt2
#>  4     unit4      trt5
#>  5     unit5      trt4
#>  6     unit6      trt4
#>  7     unit7      trt5
#>  8     unit8      trt5
#>  9     unit9      trt3
#> 10     unit10     trt2
#> # ℹ 20 more rows

deggust::autoplot(CRD1)
#> Error in `geom_unit_node()`:
#> ! Problem while converting geom to grob.
#> ℹ Error occurred in the 2nd layer.
#> Caused by error in `check.length()`:
#> ! 'gpar' element 'lwd' must not be length 0
#> Backtrace:
#>      ▆
#>   1. ├─base::tryCatch(...)
#>   2. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#>   3. │   ├─base (local) tryCatchOne(...)
#>   4. │   │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#>   5. │   └─base (local) tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#>   6. │     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>   7. │       └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#>   8. ├─base::withCallingHandlers(...)
#>   9. ├─base::saveRDS(...)
#>  10. ├─base::do.call(...)
#>  11. ├─base (local) `<fn>`(...)
#>  12. ├─global `<fn>`(input = base::quote("bosky-moa_reprex.R"))
#>  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. │       ├─base::withCallingHandlers(...)
#>  18. │       ├─knitr:::process_group(group)
#>  19. │       └─knitr:::process_group.block(group)
#>  20. │         └─knitr:::call_block(x)
#>  21. │           └─knitr:::block_exec(params)
#>  22. │             └─knitr:::eng_r(options)
#>  23. │               ├─knitr:::in_input_dir(...)
#>  24. │               │ └─knitr:::in_dir(input_dir(), expr)
#>  25. │               └─knitr (local) evaluate(...)
#>  26. │                 └─evaluate::evaluate(...)
#>  27. │                   └─evaluate:::evaluate_call(...)
#>  28. │                     ├─evaluate (local) handle(...)
#>  29. │                     │ └─base::try(f, silent = TRUE)
#>  30. │                     │   └─base::tryCatch(...)
#>  31. │                     │     └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#>  32. │                     │       └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>  33. │                     │         └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#>  34. │                     ├─base::withCallingHandlers(...)
#>  35. │                     ├─base::withVisible(value_fun(ev$value, ev$visible))
#>  36. │                     └─knitr (local) value_fun(ev$value, ev$visible)
#>  37. │                       └─knitr (local) fun(x, options = options)
#>  38. │                         ├─base::withVisible(knit_print(x, ...))
#>  39. │                         ├─knitr::knit_print(x, ...)
#>  40. │                         └─knitr:::knit_print.default(x, ...)
#>  41. │                           └─evaluate (local) normal_print(x)
#>  42. │                             ├─base::print(x)
#>  43. │                             └─ggplot2:::print.ggplot(x)
#>  44. │                               ├─ggplot2::ggplot_gtable(data)
#>  45. │                               └─ggplot2:::ggplot_gtable.ggplot_built(data)
#>  46. │                                 └─ggplot2:::by_layer(...)
#>  47. │                                   ├─rlang::try_fetch(...)
#>  48. │                                   │ ├─base::tryCatch(...)
#>  49. │                                   │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#>  50. │                                   │ │   └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>  51. │                                   │ │     └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#>  52. │                                   │ └─base::withCallingHandlers(...)
#>  53. │                                   └─ggplot2 (local) f(l = layers[[i]], d = data[[i]])
#>  54. │                                     └─l$draw_geom(d, layout)
#>  55. │                                       └─ggplot2 (local) draw_geom(..., self = self)
#>  56. │                                         └─self$geom$draw_layer(...)
#>  57. │                                           └─ggplot2 (local) draw_layer(..., self = self)
#>  58. │                                             └─base::lapply(...)
#>  59. │                                               └─ggplot2 (local) FUN(X[[i]], ...)
#>  60. │                                                 ├─rlang::inject(self$draw_panel(data, panel_params, coord, !!!params))
#>  61. │                                                 └─self$draw_panel(data, panel_params, coord)
#>  62. │                                                   └─deggust (local) draw_panel(...)
#>  63. │                                                     ├─grid::polygonGrob(...)
#>  64. │                                                     │ └─grid::grob(...)
#>  65. │                                                     └─grid::gpar(...)
#>  66. │                                                       └─grid:::validGP(list(...))
#>  67. │                                                         └─grid (local) numnotnull("lwd")
#>  68. │                                                           └─grid (local) check.length(gparname)
#>  69. │                                                             └─base::stop(...)
#>  70. └─base::.handleSimpleError(...)
#>  71.   └─rlang (local) h(simpleError(msg, call))
#>  72.     └─handlers[[1L]](cnd)
#>  73.       └─cli::cli_abort(...)
#>  74.         └─rlang::abort(...)

Created on 2023-04-10 with [reprex v2.0.2](https://reprex.tidyverse.org/)
emitanaka commented 1 year ago

Thanks! It's fixed now.