officer

How to increase resolution of ggplots when exporting using officer R

北慕城南 提交于 2019-12-23 01:54:44
问题 I want to export charts to a PPT and am using the officer package to achieve the same. However, the default resolution of the charts is low and I would like to change that. I am currently using the following call ph_with_gg(p1,type = "chart",res = 1200) where p1 is a ggplot object. On running this, I get the following error: Error in png(filename = file, width = width, height = height, units = "in", : formal argument "res" matched by multiple actual arguments Would really appreciate the help

Displaying multiple tables using Package officer and flextable

非 Y 不嫁゛ 提交于 2019-12-23 01:24:09
问题 I was wondering if it might be possible to display more than one flextable in the HTML format (on a single page) using flextable and officer ? library('flextable') library('officer') dat1 <- data.frame(Approaches = c("Y", "Y", "N"), Meets = c("N", "Y", "N"), row.names = c("Read", "Math", "Sci.")) dat2 <- data.frame(Read = "Y", Math = "N") def_par <- fp_par(text.align = "center") def_txt <- fp_text(bold = TRUE) ft <- flextable(dat1, cwidth = c(3.2, 3.2)) # Table #1 ft <- style(ft, pr_p = def

Unpredictable behavior using regex and body_replace_all_text in officer package

随声附和 提交于 2019-12-12 05:06:06
问题 I'm using body_replace_all_text() function from officer package to find and replace some tags in a word document. The behavior of the body_replace_all_text() function is unpredictable, working on some of the tags, but not on all of them. It's also weird that cursor_reach() functions find the tag, but body_replace_all_text() can't. Let's assume we have a simple word document, named "test.docx" with just these two tags: #KS_STAT# #TAG# doc_file <- read_docx("test.docx") doc_file %>% body

Powerpoint manipulation - Add a slide at an index OR delete a slide

走远了吗. 提交于 2019-12-11 15:56:09
问题 I've been bouncing between two packages for my needs. We make quite a few powerpoints at work, and I've been trying to automate the template, so all that's left to do is populate the template with data. We are pretty data heavy, and the actual content changes pretty drastically, so I'm just trying to create the template to start. I've created a master template already, which has every possible slide that I would use. Then using either officer or reporteRs, I'm deleting/editing/creating slides

R officer - Nest Dataframe Into Grouped List And Export Tables to Word With Group Headers

跟風遠走 提交于 2019-12-11 15:14:34
问题 I read a similar question that helped me get to the point I'm at now, but am struggling with the next step. I have a dataframe similar to below - Product = c("Apple", "Apple", "Banana", "Banana", "Banana", "Carrot", "Carrot") Category = c(1, 2, 1, 2, 3, 1, 2) Slope = c(2.988, 2.311, 2.181, 6.387, 2.615, 7.936, 3.267) df = data.frame(Product, Category, Slope) My objective is to have a Word report with a table for each product. To do this, I create a list with the data and flextables, as below

create pdf in addition to word docx using officer

我的梦境 提交于 2019-12-11 05:20:03
问题 I am using officer (used to use reporters) within a loop to create 150 unique documents. I need these documents however to be exported from R as word docx AND pdfs. Is there a way to export the document created with officer to a pdf? 回答1: That's possible but the solution I have depends on libreoffice. Here is the code I am using. Hope it will help. I've hard-coded libreoffice path then you probably will have to adapt or improve the code for variable cmd_ . The code is transforming a PPTX or

Adding image to flextable using function

不羁的心 提交于 2019-12-08 17:31:40
I am using Officer to create a Word document, which is a large table. Into this table I want to insert some images. To do this I am using flextable. The following code inserts an image into the flextable. pupil.tbl <- tribble( ~col1, ~col2, paste("Name:", pupil$name), paste("Class:", pupil.class), "attendance_graph", "boxall_graph" ) # add attendance plot pupil.ft <- flextable(as.data.frame(pupil.tbl)) pupil.ft <- display( pupil.ft, i=2, col_key = "col1", pattern = "{{att_tbl}}", formatters = list( att_tbl ~ as_image( col1, src = "attendance.png", width = 3.3, height = 1.65) ) ) ) This works

Adding image to flextable using function

天大地大妈咪最大 提交于 2019-12-08 03:50:52
问题 I am using Officer to create a Word document, which is a large table. Into this table I want to insert some images. To do this I am using flextable. The following code inserts an image into the flextable. pupil.tbl <- tribble( ~col1, ~col2, paste("Name:", pupil$name), paste("Class:", pupil.class), "attendance_graph", "boxall_graph" ) # add attendance plot pupil.ft <- flextable(as.data.frame(pupil.tbl)) pupil.ft <- display( pupil.ft, i=2, col_key = "col1", pattern = "{{att_tbl}}", formatters =

How to increase resolution of ggplots when exporting using officer R

末鹿安然 提交于 2019-12-08 03:47:29
I want to export charts to a PPT and am using the officer package to achieve the same. However, the default resolution of the charts is low and I would like to change that. I am currently using the following call ph_with_gg(p1,type = "chart",res = 1200) where p1 is a ggplot object. On running this, I get the following error: Error in png(filename = file, width = width, height = height, units = "in", : formal argument "res" matched by multiple actual arguments Would really appreciate the help around this C8H10N4O2 Rather than using png , for high-resolution plots in PPT you should be using

R Markdown PowerPoint Slide Customization

时光怂恿深爱的人放手 提交于 2019-12-08 03:16:50
问题 --- title: "Untitled" author: "April 2018" date: "4/9/2019" output: powerpoint_presentation --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) ``` ## Slide with Plot ```{r pressure, fig.width=30, fig.asp=0.618, out.width="200%"} plot(pressure) ``` I'm reading R Studio's guide to creating PowerPoint presentations in R Markdown. I'd like to be able to customize my slides to include two things: Stretch the image size to the full width of the slide Move the title up a bit and