r-lib / vctrs

Generic programming with typed R vectors
https://vctrs.r-lib.org
Other
290 stars 66 forks source link

Check size more carefully before calling `compact_rep()` in all places, error on long sizes #1919

Open PetiteTong opened 8 months ago

PetiteTong commented 8 months ago

data_long

A tibble: 879,802,446 × 22

refu sd_bio1 sd_bio2 sd_bio3 sd_bio4 sd_bio5 sd_bio6 sd_bio7 sd_bio8

1 0 2.73 0.304 16.9 0.411 2.95 2.74 0.992 2.75 2 0 2.73 0.304 16.9 0.411 2.95 2.74 0.992 2.75 3 0 2.73 0.304 16.9 0.411 2.95 2.74 0.992 2.75 4 0 2.73 0.304 16.9 0.411 2.95 2.74 0.992 2.75 5 0 2.73 0.304 16.9 0.411 2.95 2.74 0.992 2.75 6 0 2.73 0.304 16.9 0.411 2.95 2.74 0.992 2.75 7 0 2.73 0.308 16.9 0.414 2.95 2.73 0.977 2.74 8 0 2.73 0.308 16.9 0.414 2.95 2.73 0.977 2.74 9 0 2.73 0.308 16.9 0.414 2.95 2.73 0.977 2.74 10 0 2.73 0.308 16.9 0.414 2.95 2.73 0.977 2.74 # ℹ 879,802,436 more rows # ℹ 13 more variables: sd_bio9 , sd_bio10 , sd_bio11 , # sd_bio12 , sd_bio13 , sd_bio14 , sd_bio15 , # sd_bio16 , sd_bio17 , sd_bio18 , sd_bio19 , # Variable , Value # ℹ Use `print(n = ...)` to see more rows # 创建小提琴图和箱图,并添加渐变色 p <- ggplot(data_long, aes(x = refu, y = Value, fill = refu)) + + geom_violin() + + geom_boxplot(width = 0.2, position = position_dodge(0.75)) + + facet_wrap(~ Variable, scales = "free_y", ncol = 2) + + labs(x = "refu", y = "Value") + + scale_fill_manual(values = c('1' = "pink", '0' = "blue")) + # 手动指定颜色 + theme_minimal() # 打印小提琴图和箱图 print(p) Error in `vec_rbind()`: ! Negative `n` in `compact_rep()`. ℹ In file utils.c at line 897. ℹ Install the winch package to get additional debugging info the next time you get this error. ℹ This is an internal error that was detected in the vctrs package. Please report it at with a reprex () and the full backtrace. Backtrace: ▆ 1. ├─base::print(p) 2. ├─base::print(p) 3. ├─ggplot2:::print.ggplot(p) 4. │ ├─ggplot2::ggplot_build(x) 5. │ └─ggplot2:::ggplot_build.ggplot(x) 6. │ └─layout$setup(data, plot$data, plot$plot_env) 7. │ └─ggplot2 (local) setup(..., self = self) 8. │ └─self$facet$compute_layout(data, self$facet_params) 9. │ └─ggplot2 (local) compute_layout(..., self = self) 10. │ └─ggplot2::combine_vars(data, params$plot_env, vars, drop = params$drop) 11. │ ├─ggplot2:::unique0(vec_rbind0(!!!values[has_all])) 12. │ └─ggplot2:::vec_rbind0(!!!values[has_all]) 13. │ ├─ggplot2:::with_ordered_restart(...) 14. │ │ └─base::withCallingHandlers(...) 15. │ └─vctrs::vec_rbind(..., .error_call = .error_call) 16. └─rlang:::stop_internal_c_lib(...) 17. └─rlang::abort(message, call = call, .internal = TRUE, .frame = frame)