13. 🚧🚧 Graphics

The open-access textbook Deep R Programming by Marek Gagolewski is, and will remain, freely available for everyone’s enjoyment (also in PDF). It is a non-profit project. This book is still a work in progress. Beta versions of Chapters 1–12 are already complete, but there will be more. In the meantime, any bug/typos reports/fixes are appreciated. Although available online, it is a whole course; it should be read from the beginning to the end. Refer to the Preface for general introductory remarks. Also, check out my other book, Minimalist Data Wrangling with Python [20].

The R Project homepage advertises our free software as an environment for statistical computing and graphics. Hence, had we not dealt with the latter use case, our course would have been incomplete.

R is equipped with two independent systems for graphics generation.

  1. The (historically) newer one, grid, is quite complicated. Some readers might have come across the lattice and ggplot2 packages before: they are built on top of grid.

  2. On the other hand, its traditional (S-style) counterpart, graphics, is much easier to master. Still, it gives their users full control over the drawing process. Its being both simple, fast, and low-level makes it very attractive from the perspective of this course’s philosophy.

This is why, in this chapter, we will only cover the second approach. Note that all figures in this book were generated using graphics and its dependants. They are sufficiently aesthetic, aren’t they?

🚧 This chapter is under construction. Please come back later.

13.1. 🚧 Placeholders for Plots Referred to Elsewhere

🚧 Plotting and factors; see Figure 13.1.

plot(iris[["Sepal.Length"]],  # x (it is a vector)
     iris[["Petal.Width"]],   # y (it is a vector)
     col=as.numeric(iris[["Species"]]),  # colours

Figure 13.1 as.numeric on factors can be used to create different plotting styles