使用tidy工具链触发pillar包colonnade()弃用错误,寻求修复方案
解决pillar包
colonnade()已废弃的错误 我长期使用R语言,近几个月执行tidy相关操作后频繁出现以下错误:
Error: ! `colonnade()` was deprecated in pillar 1.9.0 and is now defunct. i Please use `tbl_format_setup()` instead. Run `rlang::last_trace()` to see where the error occurred.
目前可通过调用as.data.frame(df)临时解决,但操作繁琐。推测是依赖问题,但因担心破坏库环境不敢随意调整,尝试更新包后问题仍存在。
会话信息
sessionInfo() R version 4.0.2 (2020-06-22) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044) Matrix products: default locale: [1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C [5] LC_TIME=English_United Kingdom.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] plm_2.2-4 urca_1.3-0 tseries_0.10-48 aTSA_3.1.2 stargazer_5.2.2 data.table_1.13.0 lubridate_1.7.9 readxl_1.3.1 forcats_0.5.0 [10] stringr_1.4.0 dplyr_1.0.2 purrr_0.3.4 readr_2.1.4 tidyr_1.1.2 tibble_3.0.3 ggplot2_3.4.4 tidyverse_1.3.0 loaded via a namespace (and not attached): [1] httr_1.4.2 jsonlite_1.8.4 modelr_0.1.8 Formula_1.2-3 Rdpack_1.0.0 assertthat_0.2.1 TTR_0.24.2 blob_1.2.1 cellranger_1.1.0 [10] pillar_1.9.0 backports_1.1.9 lattice_0.20-41 glue_1.4.2 quadprog_1.5-8 digest_0.6.25 rvest_0.3.6 colorspace_1.4-1 sandwich_2.5-1 [19] pkgconfig_2.0.3 bibtex_0.4.2.3 broom_0.8.0 haven_2.3.1 scales_1.2.1 stringdist_0.9.8 tzdb_0.3.0 generics_0.1.3 farver_2.0.3 [28] ellipsis_0.3.2 withr_2.5.2 maxLik_1.4-4 cli_3.6.1 quantmod_0.4.18 vars_1.5-6 strucchange_1.5-2 magrittr_1.5 crayon_1.3.4 [37] fs_1.5.0 fansi_0.4.1 nlme_3.1-148 MASS_7.3-51.6 xts_0.12.1 xml2_1.3.2 tools_4.0.2 hms_0.5.3 gbRd_0.4-11 [46] lifecycle_1.0.3 munsell_0.5.0 reprex_0.3.0 compiler_4.0.2 rlang_1.1.1 grid_4.0.2 miscTools_0.6-26 rstudioapi_0.11 labeling_0.3 [55] gtable_0.3.0 DBI_1.1.0 curl_4.3 R6_2.5.0 zoo_1.8-8 bdsmatrix_1.3-4 utf8_1.1.4 stringi_1.4.6 matrixcalc_1.0-5 [64] parallel_4.0.2 Rcpp_1.0.5 vctrs_0.6.2 dbplyr_1.4.4 tidyselect_1.1.0 lmtest_0.9-38
错误追踪信息
> rlang::last_trace(drop = FALSE) <error/lifecycle_error_deprecated> Error: ! `colonnade()` was deprecated in pillar 1.9.0 and is now defunct. i Please use `tbl_format_setup()` instead. --- Backtrace: x 1. +-base (local) `<fn>`(x) 2. \-tibble:::print.tbl(x) 3. +-cli::cat_line(format(x, ..., n = n, width = width, n_extra = n_extra)) 4. | \-base::paste0(..., collapse = "\n") 5. +-base::format(x, ..., n = n, width = width, n_extra = n_extra) 6. \-tibble:::format.tbl(x, ..., n = n, width = width, n_extra = n_extra) 7. \-tibble::trunc_mat(x, n = n, width = width, n_extra = n_extra) 8. \-tibble:::shrink_mat(df, rows, n, star = has_rownames(x)) 9. \-pillar::colonnade(df, has_row_id = if (star) "*" else TRUE) 10. \-lifecycle::deprecate_stop("1.9.0", "pillar::colonnade()", "pillar::tbl_format_setup()") 11. \-lifecycle:::deprecate_stop0(msg) 12. \-rlang::cnd_signal(...)
修复方法
- 核心原因:当前使用的
tibble_3.0.3版本过旧,与最新的pillar_1.9.0不兼容——旧版tibble仍在调用已被pillar废弃的colonnade()函数。 - 具体修复步骤:
- 更新
tibble包到兼容版本:执行以下命令,确保安装后版本≥3.2.0(该版本已将colonnade()调用替换为tbl_format_setup())install.packages("tibble") - 若更新tibble后问题仍存在,更新整个tidyverse套件以保证所有依赖版本匹配:
install.packages("tidyverse") - 环境隔离方案:如果担心破坏现有库环境,可使用
renv创建独立的项目环境,在隔离环境中更新包进行测试,避免影响全局R库。
- 更新
- 验证:更新完成后,重新运行之前报错的tidy相关操作,检查是否还出现
colonnade()相关错误。
内容的提问来源于stack exchange,提问作者Macascu
相关产品推荐
相关产品推荐

