How to create PowerPoint reports with R

How to create PowerPoint reports with R

File Manipulation, R
In my last post, we discussed how to create and read Word files with R's officer package. This article will expand on officer by showing how we can use it to create PowerPoint reports. Getting started Let's get started by loading officer. [code lang="R"] library(officer) [/code] Next, we'll create a PowerPoint object in R using the read_pptx function. [code lang="R"] pres <- read_pptx() [/code] To add a slide, we use the add_slide function. The first slide we'll create is the title slide. We specify the type of slide in the layout parameter. There's several other possibilities here including "Title and Content", "Blank", "Title Only", "Comparison", "Two Content", and "Section Header". Secondly, we use ph_with to add the title text. [code lang="R"] # add title slide pres <- add_slide(pres, layout =…
Read More
How to read and create Word Documents in R

How to read and create Word Documents in R

File Manipulation, R
Reading and creating word documents in R In this post we'll talk about how to use R to read and create word files. We'll primarily be using R's officer package. For reading data from Word Documents with Python, click here. Creating Word reports with the officer package The first thing we need to do is to install the officer package. [code lang="R"] install.packages("officer") [/code] We'll also be using the dplyr package, so you'll need to install that the same way if you don't have it already. Next, let's load each of these packages. [code lang="R"] library(officer) library(dplyr) [/code] Now, we'll get started creating a report! First, we will use the read_docx function to create an empty Word file. [code lang="R"] # create empty Word file sample_doc <- read_docx() [/code] Adding…
Read More