qfes / rdeck

Deck.gl widget for R
https://qfes.github.io/rdeck
MIT License
97 stars 0 forks source link

Layers with `scale_quantile` fail to build #108

Closed anthonynorth closed 7 months ago

anthonynorth commented 10 months ago

scale_quantile() isn't working. Reprex:

layer_data <- vctrs::data_frame(
  position = rdeck::xy(runif(1e3, -180, 180), runif(1e3, -85, 85)),
  value = rnorm(1e3)
)

rdeck::rdeck() |>
  rdeck::add_scatterplot_layer(
    data = layer_data,
    # err
    get_radius = rdeck::scale_quantile(value)
  )
#> Error:
#> ! `data` must be uniquely named but has duplicate columns
#> 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("smoky-macaw_reprex.R"))
#>  13. │ └─rmarkdown::render(input, quiet = TRUE, envir = globalenv(), encoding = "UTF-8")
#>  14. │   └─knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet) at rmarkdown/R/render.R:768:4
#>  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. │                         └─htmlwidgets:::knit_print.htmlwidget(x, ...)
#>  41. │                           ├─knitr::knit_print(...)
#>  42. │                           │ └─knitr:::need_screenshot(x, ...)
#>  43. │                           └─htmlwidgets:::toHTML(x, standalone = FALSE, knitrOptions = options)
#>  44. │                             ├─htmltools::tagList(...)
#>  45. │                             │ └─rlang::dots_list(...)
#>  46. │                             └─htmlwidgets:::widget_data(x, x$id)
#>  47. │                               ├─htmlwidgets:::toJSON(createPayload(x))
#>  48. │                               └─htmlwidgets:::createPayload(x)
#>  49. │                                 └─instance$preRenderHook(instance)
#>  50. │                                   └─rdeck:::mutate(rdeck, x = as_json(x))
#>  51. │                                     └─purrr::reduce2(nms, quos, .init = lst, mutate_col)
#>  52. │                                       └─purrr:::reduce2_impl(.x, .y, .f, ..., .init = .init, .left = TRUE)
#>  53. │                                         └─rdeck (local) .f(out, .x[[x_i]], .y[[y_i]], ...)
#>  54. │                                           └─rlang::eval_tidy(quo, data)
#>  55. ├─rdeck:::as_json(x)
#>  56. ├─rdeck:::as_json.rdeck_data(x)
#>  57. │ └─rdeck:::mutate(rdeck_data, layers = lapply(layers, function(layer) as_json(layer)))
#>  58. │   └─purrr::reduce2(nms, quos, .init = lst, mutate_col)
#>  59. │     └─purrr:::reduce2_impl(.x, .y, .f, ..., .init = .init, .left = TRUE)
#>  60. │       └─rdeck (local) .f(out, .x[[x_i]], .y[[y_i]], ...)
#>  61. │         └─rlang::eval_tidy(quo, data)
#>  62. ├─base::lapply(layers, function(layer) as_json(layer))
#>  63. │ └─rdeck (local) FUN(X[[i]], ...)
#>  64. │   ├─rdeck:::as_json(layer)
#>  65. │   └─rdeck:::as_json.layer(layer)
#>  66. │     ├─rdeck:::json_stringify(...)
#>  67. │     │ └─rdeck:::to_camel_case(names(object))
#>  68. │     │   └─base::gsub("(?<!^)_+(\\w)", "\\U\\1", x, perl = TRUE)
#>  69. │     │     └─base::is.factor(x)
#>  70. │     └─base::lapply(layer, function(x) as_json(x, cols = cols, dims = dims))
#>  71. │       └─rdeck (local) FUN(X[[i]], ...)
#>  72. │         ├─rdeck:::as_json(x, cols = cols, dims = dims)
#>  73. │         └─rdeck:::as_json.scale(x, cols = cols, dims = dims)
#>  74. │           ├─rdeck:::mutate(...)
#>  75. │           │ └─purrr::reduce2(nms, quos, .init = lst, mutate_col)
#>  76. │           │   └─purrr:::reduce2_impl(.x, .y, .f, ..., .init = .init, .left = TRUE)
#>  77. │           │     └─purrr:::reduce_init(.x, .init, left = .left, error_call = .purrr_error_call)
#>  78. │           ├─generics::compile(object)
#>  79. │           └─rdeck:::compile.scale_numeric_quantile(object)
#>  80. │             └─rdeck:::mutate(rename(object, limits = data), scale_type = "threshold")
#>  81. │               └─purrr::reduce2(nms, quos, .init = lst, mutate_col)
#>  82. │                 └─purrr:::reduce2_impl(.x, .y, .f, ..., .init = .init, .left = TRUE)
#>  83. │                   └─rdeck (local) .f(out, .x[[x_i]], .y[[y_i]], ...)
#>  84. │                     └─rlang::eval_tidy(quo, data)
#>  85. └─rlang::abort(message = message)

Created on 2023-11-07 with reprex v2.0.2