-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
Description
书籍用到了很多 R 包,一些 R 包处于活跃开发和变动中,现将问题记录于此,以便跟进。如下都是一些对书籍影响比较大的 R 包,而且这些 R 包本身影响力也比较大,比如 ggplot2、 spatstat、 gt、 echarts4r 等
ggplot2
问题解决后就勾掉
- 11月中旬集中更新一次软件包,然后启用 renv 版本管理,摁住版本,直到把书写完。renv 不好弄,还是用 DESC 文件管理,尝试使用 renv 做版本管理,但是失败了,总是安装 cmdstanr 失败,找不到,可见 renv 不能识别 CMDSTAN 仓库,继续使用 DESC 文件管理 R 包依赖。
- ggbump 没有经常维护, ggplot2 和 vctrs 升级后,导致 ggbump 更加不稳定,代码无法运行。
https://github.com/davidsjoberg/ggstream 也是,因此不值得被介绍,后续要移除或类似瀑布图、时间轴图重新从零开始制作。 - 还影响了 bayesplot 包,导致无法绘制后验分布图,详见 Issues with next version of ggplot2 stan-dev/bayesplot#289
- ggplot2 从版本 3.4.0 开始,视觉映射 size 被替换为 linewidth ,size 会无效。
而在版本 3.4.0 之前,如果使用 linewidth 会报警告问题 Warning: Ignoring unknown parameters: linewidth 详见 - Rename size aesthetic for line-based geoms tidyverse/ggplot2#3672
- https://www.tidyverse.org/blog/2022/08/ggplot2-3-4-0-size-to-linewidth/
由于 ggplot2 3.4.0 的改动导致本书使用的一些下游 R 包报出警告,预计 2022 年10月底之前发布 3.4.0 版本。
- ggmosaic Warning from tidyr re unite_() deprecation haleyjeppson/ggmosaic#60
- likert Warning message: The
size
argument ofelement_rect()
is deprecated as of ggplot2 3.4.0. jbryer/likert#127 - ggtern https://github.com/leogama/ggtern
- ggraph 网络图 https://github.com/thomasp85/ggraph Deprecation warning for size aesthetic thrown by geom_edge_link (and similar) since ggplot2 version 3.4.0 thomasp85/ggraph#333
- ggalluvial 待发布新版
书中用到以下 R 包的开发版,待新的稳定版本发布后,可以更新 DESCRIPTION 文件
- davidsjoberg/ggbump 凹凸图 https://github.com/davidsjoberg/ggbump
- giocomai/ganttrify 甘特图 https://github.com/giocomai/ganttrify
- ricardo-bion/ggradar 雷达图 https://github.com/ricardo-bion/ggradar
- ggsurvfit 与 ggplot2 3.5.0 有不兼容的地方 生存分析图 https://github.com/pharmaverse/ggsurvfit
ggsurvfit(aml_ggsurvfit, linewidth = 1) + add_confidence_interval() + add_risktable()
Warning messages: 1: In ggplot2::geom_blank() : All aesthetics have length 1, but the data has 22 rows. ℹ Did you mean to use `annotate()`? 2: In ggplot2::geom_blank() : All aesthetics have length 1, but the data has 22 rows. ℹ Did you mean to use `annotate()`? 3: In ggplot2::geom_blank() : All aesthetics have length 1, but the data has 22 rows. ℹ Did you mean to use `annotate()`? 4: In ggplot2::geom_blank() : All aesthetics have length 1, but the data has 22 rows. ℹ Did you mean to use `annotate()`? 5: In ggplot2::geom_blank() : All aesthetics have length 1, but the data has 22 rows. ℹ Did you mean to use `annotate()`?
spatstat
- spatstat 版本 3.0-0 以后 spatstat.core 包被拆分成 spatstat.explore 和 spatstat.model 两个包,届时得用 spatstat.explore::density.ppp 替换 spatstat.core::density.ppp 详见 https://github.com/spatstat/spatstat/blob/master/NEWS
DT
gt
简单的表格可以一律用 knitr::kable
来做,复杂的表格可以一律用 gt 包做,主要考虑到 gt 的活跃开发现状, gt 和 Quarto 的紧密结合,以及 gt 的扩展生态(比如 gtExtra / gtreg),以及 gt 和 Quarto 都属于 RStudio 大厂持续维护和高投入。
gt gtsummary gtreg gtExtras 等包的文档见 https://github.com/jthomasmock
模型输出考虑 gtsummary 或者 modelsummary
Word 输出中,交叉引用功能失效,需要 Quarto 和相关表格包互相支持,预计 Quarto 1.4 会支持。
- gt 使用 reactable 将静态表格转为交互表格,因此,后续介绍交互表格将基于 reactable 包
- gt 的
cols_width()
目前不支持 LaTeX 输出,对于复杂表格有点麻烦 Column widths not porting to LaTeX rstudio/gt#634 - 用 gt 包制作复杂表格,展示 anscombe 数据(列分组的),展示 UCBAdmissions 数据(列分层分组)
- flextable 在 docx 格式输出中丢失交叉引用,且使用方式和其它包不太一样,配合管道操作还不错。
- kableExtra 若设置样式,则可能影响其它位置的表格。面对 HTML 和 PDF 输出 kableExtra 需要两套代码。在 PDF 输出中丢失交叉引用,不支持 DOCX 输出。不经常维护,不推荐使用。
- DOCX 格式输出,两个表格丢失引用,应该是 gt 包的问题 详见
tab_spanner()
does not work as intended when output format is docx rstudio/gt#994
WARNING: Unable to resolve crossref @tbl-anscombe-datasets
WARNING: Unable to resolve crossref @tbl-ucb-admissions
已报告,详见 rstudio/gt#1140
- gt 包使用 tab_spanner 实现列分组,但是列分组在 Word 中不支持,表格整个是乱掉的。但是在 HTML / PDF / EPUB 中是好的。
emo
- emo 的 Emoji 图在 Ubuntu 上渲染正常,在 MacOS 上渲染失败。
这确实是与系统有关系的,详见 https://stackoverflow.com/questions/52378661
echarts4r
- 斐济地震数据 quakes,制作三维气泡图,size 和 color 不能同时映射给 mag 变量 e_visual_map doesn't respect color and size in e_scatter_3d simultaneously JohnCoene/echarts4r#474
最近的进展详见论坛讨论 https://d.cosx.org/d/423701 待 echarts4r 更新至 0.4.5 后勾掉