Chapter 7. Developing Static Reports

In this chapter, we will cover the following topics:

  • Using one markup language for all types of documents – rmarkdown
  • Writing and styling PDF documents with RStudio
  • Writing wonderful tufte handouts with the tufte package and rmarkdown
  • Sharing your code and plots with slides
  • Curating a blog through RStudio

Introduction

In this chapter, we will provide tools for the last part of your data-analysis project: result sharing. This is a relevant phase since your work will give no added value if you do not effectively communicate it.

You know this is true, but how do you do it?

The answer to this question can be split into two parts:

  • The marketing part
  • The technical part

Let’s first briefly address the first part, since the second one will be addressed throughout the chapter. Talking about the marketing part, I refer to all those strategies and activities you perform to sell your product better. Your product is your job, and if you don’t sell it properly, nobody is going to buy it and you would have wasted your time.

This is not the right place to address the point in a proper and complete way, but let me stress at least two points:

  • Do not show data, tell a story with it: I know you are really proud of having found a unexpected correlation between that variable and your revenues, but just showing a correlation coefficient will not thrill anyone (except you). You should rather ask, “What story does it tell? Does it mean we can influence our revenues by pushing hard on that given variable?” OK, if you think so, show it. Say aloud that “by increasing expenditure on this, we can grow our revenue by 25 percent.” Isn’t this better than a correlation coefficient?
  • Always ask yourself, “So what?”: When you are crafting your report, you should always imagine that you have someone in front of you who asks, “So what?” If you are able to answer this question in a convincing way, you are preparing to win (and sell). Let’s try it. We say, “We found that the number of injuries suffered in a year by a person is strongly correlated to his age (surprise!), which is a significant variable for our retention rate.” The impolite man says, “So what?” We reply, “So, we can reduce our research costs by avoiding acquiring data about injuries”. So that’s the point: expenditure cuts!

Let’s face the technical part now. In the modern world, the more precious resource is time. It is therefore considered a waste of time copying and pasting results from your job into a file external to your coding environment, and copying and pasting it again when even a small detail changes.

This process can also be considered error prone. Within your copy-and-paste activity, you can bet a considerable sum on forgetting to update some values and sending your boss outdated numbers. This, as we know, is not a pleasant experience.

This chapter will help you avoid such unpleasant scenarios and give you great tools to develop reports on your work directly from the place where it was produced: RStudio. In this chapter, you will learn how to develop reports directly by embedding numbers, plots, and data frames from your code. When you change the code and outputs change, your report will change by itself.

Doesn’t it sound like a dream?

Our best friend in this chapter, and part of the next one as well, will be rmarkdown, a powered markup language. It lets you embed and execute pieces of R code within documents written in the Markdown language, the popular markup language created by Joghn Gruber in 2004. We will employ rmarkdown in this chapter to write reports, PDF documents, and tufte handouts. We will also use rmarkdown to curate a blog directly from your favorite IDE.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset