The goal of this chapter is to enable you to create different types of graphs in R. In Chapter 1, Base Graphics in R – One Step at a Time, you created scatterplots and line plots. Now in this chapter, you will learn how to create other types of graphs, including bar charts, histograms, boxplots, pie charts, and dotcharts. Topics covered in this chapter include the following:
After working through this chapter, you should understand the principles behind certain advanced plotting functions and should be able to create a wide range of graphs for research and analysis.
Several datasets have been created for this book and can be downloaded from the website for this book as text files. These text files also provide the R code for each chapter. Alternatively, copy the relevant CSV file into a convenient folder, make sure that the R working directory matches your folder, and use the read.csv()
command. For example, to read a CSV file called Patients
as the object T
, enter the following syntax:
T <- read.csv("Patients.csv", h=T)
Further explanations on reading datasets will be given in this chapter.