![]() Moving forward we're going to refer to our uploaded image as image and the R-generated plot as figure. The plot is created using the package ggplot2. In this post we'll work with a pre-existing image as well as a dynamically generated plot. Our examples: one pre-existing image and one dynamically generated plot More functionality from include_graphics.Bonus knitr and R markdown functionality.Optimize R-generated images with optipng or pngquant.The fig.retina argument is a resolution multiplier.Use dpi to change the resolution of images and figures.Arguments out.width and out.height apply to both existing images and R-generated figures.Use fig.width and fig.height for R-generated figures only.Default settings for including images and figures in R Markdown.Our examples: one pre-existing image and one dynamically generated plot.In this post, we report image dimensions as they appear at full size on a computer monitor for reference. NOTE 2: Images in the final HTML documents are responsive – meaning that their dimensions may change with changes to the browser view size. NOTE 1: This post is focused on the production of HTML documents and some of our conclusions and recommendations may not apply if you're using R Markdown to create a LaTeX document, PDF or Word document. We assembled this blog post to help guide you through image processing decision-making as you construct your own R Markdown reports. R Markdown offers a wide range of functions and arguments for full control of image sizes but knowing how and when to use them can be daunting particularly given the differences in how external images are handled vs R-generated figures. R Markdown reports that are heavy on graphs and maps, though, can yield large HTML files that are not optimized for web viewing. You should receive an HTML file with the same name as R Markdown document (such as xaringan-example.html), as shown in Figure 8.1.Writing reports in R Markdown allows you to skip painful and error-prone copy-paste in favor of dynamically-generated reports written in R and markdown that are easily reproducible and updateable. Try clicking the Knit button to see what this looks like. ![]() ![]() The moon_reader output format takes R Markdown documents and knits them as slides. The average bill length is `r average_bill_length` millimeters. title: "Penguins Report" author: "David Keyes" date: "" output: xaringan::moon_reader - ``` average_bill_length % summarize(avg_bill_length = mean(bill_length_mm, na.rm = TRUE)) %>% pull(avg_bill_length) ``` The chart shows the distribution of bill lengths. Making presentations with xaringan lets more people engage with your slides. For example, people with limited vision can access HTML documents in ways that allow them to view the content, such as by increasing the text size or using screen readers. HTML documents are easy to manipulate, giving viewers control over their appearance. We’ll discuss ways to publish your presentations online in Chapter 9.Ī second benefit of using xaringan is accessibility. Instead, you can send someone the presentation by just sharing a link. For instance, because xaringan creates slides as HTML documents, you can post them online without needing to email them or print them out for viewers. She argues that the package’s benefits go well beyond making good-looking slides. Silvia Canelón, a data analyst in the Urban Health Lab at the University of Pennsylvania, has taught the xaringan package extensively. However, using the xaringan package provides advantages over these options. In R Studio, you might have noticed that the Presentation option you see when creating a new R Markdown document provides several options for making slides, such as knitting an R Markdown document to PowerPoint.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |