简体   繁体   中英

Officer package in R

All the ph_with_* functions have been deprecated. Is there a way if I can still use the old version of officer and flextable which will allow me to use ph_with_* functions. I have an automated process and due to the new version, I am having a hard time making all the changes

It should be possible. If you know the particular version number (you can check the changelog ), just look to the archive , copy the URL of your version and run eg:

install.packages("https://cran.r-project.org/src/contrib/Archive/officer/officer_0.1.0.tar.gz",
                 repos = NULL, type = "source")

Or use devtools package:

devtools::install_version("officer",
                          version = "0.1.0",
                          repos = "http://cran.r-project.org")

The same comes for flextable package with its changelog and CRAN archive .

Example

I have tried the following:

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")

And the example with ph_with_flextable_at() from the documentation works properly:

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM