【发布时间】:2020-10-24 02:14:45
【问题描述】:
所有 ph_with_* 函数已被弃用。如果我仍然可以使用旧版本的officer和flextable,有什么办法可以让我使用ph_with_*函数。我有一个自动化流程,由于新版本的原因,我很难进行所有更改
【问题讨论】:
所有 ph_with_* 函数已被弃用。如果我仍然可以使用旧版本的officer和flextable,有什么办法可以让我使用ph_with_*函数。我有一个自动化流程,由于新版本的原因,我很难进行所有更改
【问题讨论】:
应该是可以的。如果您知道特定的版本号(您可以查看changelog),只需查看archive,复制您的版本的 URL 并运行例如:
install.packages("https://cran.r-project.org/src/contrib/Archive/officer/officer_0.1.0.tar.gz",
repos = NULL, type = "source")
或者使用devtools包:
devtools::install_version("officer",
version = "0.1.0",
repos = "http://cran.r-project.org")
flextable 包的changelog 和CRAN archive 也是如此。
我尝试了以下方法:
devtools::install_version("officer",
version = "0.3.2",
repos = "http://cran.r-project.org")
devtools::install_version("officer",
version = "0.4.4",
repos = "http://cran.r-project.org")
文档中带有ph_with_flextable_at() 的示例可以正常工作:
library(officer)
library(flextable)
ft <- flextable(head(mtcars))
doc <- read_pptx()
doc <- add_slide(doc, layout = "Title and Content",
master = "Office Theme")
doc <- ph_with_flextable(doc, value = ft, type = "body")
doc <- ph_with_flextable_at(doc, value = ft, left = 4, top = 5)
print(doc, target = "test.pptx")
【讨论】:
officer 0.3.2 和flextable 0.4.4(因为它们同时出现)和ph_with_flextable_at() 的基本脚本对我来说正常工作,没有任何警告或错误 - 我有更新了答案,请尝试。