bar %įilter(year = max(year)) %>% # most recent year only The first plot I’m going to make is a bar chart of life expectancy by country for the most recent year of data, 2007. # country continent year lifeExp pop gdpPercap ![]() There is one row per country per year, with life expectancy, population, and GDP for each observation. If you haven’t worked with the gapminder data before, take a peak. Mutate(country = fct_reorder2(country, year, lifeExp)) # reorder for plotting I’m going to start by making the plots and then I’ll combine them in a single layout, and finally render the image to PowerPoint.įirst, I load the needed packages and filter the gapminder data to the five countries in East Africa I’m going to be examining. On my slide, I want to include 2 plots and 1 table related to life expectancy of certain counties in East Africa. I’m going to use data from the gapminder package, so if you don’t have it installed: install.packages("gapminder") In this post, I show how to combine plots and tables using patchwork to create multi-image PowerPoint slides using R Markdown. An alternative to using PowerPoint would be xaringan and doing some fancy layout using CSS, but I’m not very good at CSS and we need the slides in PowerPoint format because other folks at the office add additional slides to the presentations I generate.Īround this time, I was reading tweets about new development on the patchwork package for arranging ggplot objects, and thought that instead of including multiple images on one slide, I could just create a multi-image layout in R and then render that layout to the PowerPoint slide. That is a bummer for me because the original PowerPoint slides I am trying to replicate using R Markdown have multiple images and tables on them. When you have a text paragraph and an image on the same slide, the image will be moved to a new slide automatically. ![]() The only elements that can coexist with an image or table on a slide are the slide header and image/table caption. Images and tables will always be placed on new slides. In general, this is a pretty straightforward process and is described in R Markdown: The Definitive Guide. ![]() Recently at work, I’ve been building R Markdown documents to generate PowerPoint slides.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |