O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

R Graphics Cookbook, 2nd Edition

Book Description

The updated edition of this practical guide provides more than 150 recipes to help you generate high-quality graphs quickly, without having to comb through all the details of R’s graphing systems. Each recipe tackles a specific problem with a solution you can apply to your own project, and includes a discussion of how and why the recipe works.

Most of the recipes in this edition use the updated version of the ggplot2 package, a powerful and flexible way to make graphs in R. You’ll also find expanded content about the visual design of graphics. If you have a basic understanding of the R language, you’re ready to get started.

With Early Release ebooks, you get books in their earliest form—the author's raw and unedited content as he or she writes—so you can take advantage of these technologies long before the official release of these titles. You'll also receive updates when significant changes are made, new chapters are available, and the final ebook bundle is released.

Table of Contents

  1. R Basics
    1. 1.1. Installing a Package
    2. 1.2. Loading a Package
    3. 1.3. Loading a Delimited Text Data File
    4. 1.4. Loading Data from an Excel File
    5. 1.5. Loading Data from SPSS/SAS/Stata Files
  2. Quickly Exploring Data
    1. 2.1. Creating a Scatter Plot
    2. 2.2. Creating a Line Graph
    3. 2.3. Creating a Bar Graph
    4. 2.4. Creating a Histogram
    5. 2.5. Creating a Box Plot
    6. 2.6. Plotting a Function Curve
  3. Bar Graphs
    1. 3.1. Making a Basic Bar Graph
    2. 3.2. Grouping Bars Together
    3. 3.3. Making a Bar Graph of Counts
    4. 3.4. Using Colors in a Bar Graph
    5. 3.5. Coloring Negative and Positive Bars Differently
    6. 3.6. Adjusting Bar Width and Spacing
    7. 3.7. Making a Stacked Bar Graph
    8. 3.8. Making a Proportional Stacked Bar Graph
    9. 3.9. Adding Labels to a Bar Graph
    10. 3.10. Making a Cleveland Dot Plot
  4. Line Graphs
    1. 4.1. Making a Basic Line Graph
    2. 4.2. Adding Points to a Line Graph
    3. 4.3. Making a Line Graph with Multiple Lines
    4. 4.4. Changing the Appearance of Lines
    5. 4.5. Changing the Appearance of Points
    6. 4.6. Making a Graph with a Shaded Area
    7. 4.7. Making a Stacked Area Graph
    8. 4.8. Making a Proportional Stacked Area Graph
    9. 4.9. Adding a Confidence Region
  5. Scatter Plots
    1. 5.1. Making a Basic Scatter Plot
    2. 5.2. Grouping Data Points by a Variable Using Shape or Color
    3. 5.3. Using Different Point Shapes
    4. 5.4. Mapping a Continuous Variable to Color or Size
    5. 5.5. Dealing with Overplotting
    6. 5.6. Adding Fitted Regression Model Lines
    7. 5.7. Adding Fitted Lines from an Existing Model
    8. 5.8. Adding Fitted Lines from Multiple Existing Models
    9. 5.9. Adding Annotations with Model Coefficients
    10. 5.10. Adding Marginal Rugs to a Scatter Plot
    11. 5.11. Labeling Points in a Scatter Plot
    12. 5.12. Creating a Balloon Plot
    13. 5.13. Making a Scatter Plot Matrix
  6. Summarized Data Distributions
    1. 6.1. Making a Basic Histogram
    2. 6.2. Making Multiple Histograms from Grouped Data
    3. 6.3. Making a Density Curve
    4. 6.4. Making Multiple Density Curves from Grouped Data
    5. 6.5. Making a Frequency Polygon
    6. 6.6. Making a Basic Box Plot
    7. 6.7. Adding Notches to a Box Plot
    8. 6.8. Adding Means to a Box Plot
    9. 6.9. Making a Violin Plot
    10. 6.10. Making a Dot Plot
    11. 6.11. Making Multiple Dot Plots for Grouped Data
    12. 6.12. Making a Density Plot of Two-Dimensional Data