Chapter 2. Advanced Functions in Base Graphics

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:

  • Including a regression line and residuals in your graph
  • Creating complex multiple axes
  • Including grid lines and point labels
  • Shading and coloring your graph
  • Creating bar charts, histograms, boxplots, pie charts, and dotcharts
  • Adding LOWESS smoothers to your graph
  • Creating scatterplot matrices
  • Adding error bars

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.

Reading datasets into R

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.

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

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