Book description
This practical guide provides more than 150 recipes to help you generate highquality 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 use the ggplot2 package, a powerful and flexible way to make graphs in R. If you have a basic understanding of the R language, you’re ready to get started.
 Use R’s default graphics for quick exploration of data
 Create a variety of bar graphs, line graphs, and scatter plots
 Summarize data distributions with histograms, density curves, box plots, and other examples
 Provide annotations to help viewers interpret data
 Control the overall appearance of graphics
 Render data groups alongside each other for easy comparison
 Use colors in plots
 Create network graphs, heat maps, and 3D scatter plots
 Structure data for graphing
Publisher resources
Table of contents
 A Note Regarding Supplemental Files
 Preface
 1. R Basics
 2. Quickly Exploring Data

3. Bar Graphs
 Making a Basic Bar Graph
 Grouping Bars Together
 Making a Bar Graph of Counts
 Using Colors in a Bar Graph
 Coloring Negative and Positive Bars Differently
 Adjusting Bar Width and Spacing
 Making a Stacked Bar Graph
 Making a Proportional Stacked Bar Graph
 Adding Labels to a Bar Graph
 Making a Cleveland Dot Plot
 4. Line Graphs

5. Scatter Plots
 Making a Basic Scatter Plot
 Grouping Data Points by a Variable Using Shape or Color
 Using Different Point Shapes
 Mapping a Continuous Variable to Color or Size
 Dealing with Overplotting
 Adding Fitted Regression Model Lines
 Adding Fitted Lines from an Existing Model
 Adding Fitted Lines from Multiple Existing Models
 Adding Annotations with Model Coefficients
 Adding Marginal Rugs to a Scatter Plot
 Labeling Points in a Scatter Plot
 Creating a Balloon Plot
 Making a Scatter Plot Matrix

6. Summarized Data Distributions
 Making a Basic Histogram
 Making Multiple Histograms from Grouped Data
 Making a Density Curve
 Making Multiple Density Curves from Grouped Data
 Making a Frequency Polygon
 Making a Basic Box Plot
 Adding Notches to a Box Plot
 Adding Means to a Box Plot
 Making a Violin Plot
 Making a Dot Plot
 Making Multiple Dot Plots for Grouped Data
 Making a Density Plot of TwoDimensional Data
 7. Annotations

8. Axes
 Swapping X and YAxes
 Setting the Range of a Continuous Axis
 Reversing a Continuous Axis
 Changing the Order of Items on a Categorical Axis
 Setting the Scaling Ratio of the X and YAxes
 Setting the Positions of Tick Marks
 Removing Tick Marks and Labels
 Changing the Text of Tick Labels
 Changing the Appearance of Tick Labels
 Changing the Text of Axis Labels
 Removing Axis Labels
 Changing the Appearance of Axis Labels
 Showing Lines Along the Axes
 Using a Logarithmic Axis
 Adding Ticks for a Logarithmic Axis
 Making a Circular Graph
 Using Dates on an Axis
 Using Relative Times on an Axis
 9. Controlling the Overall Appearance of Graphs

10. Legends
 Removing the Legend
 Changing the Position of a Legend
 Changing the Order of Items in a Legend
 Reversing the Order of Items in a Legend
 Changing a Legend Title
 Changing the Appearance of a Legend Title
 Removing a Legend Title
 Changing the Labels in a Legend
 Changing the Appearance of Legend Labels
 Using Labels with Multiple Lines of Text
 11. Facets
 12. Using Colors in Plots

13. Miscellaneous Graphs
 Making a Correlation Matrix
 Plotting a Function
 Shading a Subregion Under a Function Curve
 Creating a Network Graph
 Using Text Labels in a Network Graph
 Creating a Heat Map
 Creating a ThreeDimensional Scatter Plot
 Adding a Prediction Surface to a ThreeDimensional Plot
 Saving a ThreeDimensional Plot
 Animating a ThreeDimensional Plot
 Creating a Dendrogram
 Creating a Vector Field
 Creating a QQ Plot
 Creating a Graph of an Empirical Cumulative Distribution Function
 Creating a Mosaic Plot
 Creating a Pie Chart
 Creating a Map
 Creating a Choropleth Map
 Making a Map with a Clean Background
 Creating a Map from a Shapefile
 14. Output for Presentation

15. Getting Your Data into Shape
 Creating a Data Frame
 Getting Information About a Data Structure
 Adding a Column to a Data Frame
 Deleting a Column from a Data Frame
 Renaming Columns in a Data Frame
 Reordering Columns in a Data Frame
 Getting a Subset of a Data Frame
 Changing the Order of Factor Levels
 Changing the Order of Factor Levels Based on Data Values
 Changing the Names of Factor Levels
 Removing Unused Levels from a Factor
 Changing the Names of Items in a Character Vector
 Recoding a Categorical Variable to Another Categorical Variable
 Recoding a Continuous Variable to a Categorical Variable
 Transforming Variables
 Transforming Variables by Group
 Summarizing Data by Groups
 Summarizing Data with Standard Errors and Confidence Intervals
 Converting Data from Wide to Long
 Converting Data from Long to Wide
 Converting a Time Series Object to Times and Values
 A. Introduction to ggplot2
 Index
 About the Author
 Colophon
 Copyright
Product information
 Title: R Graphics Cookbook
 Author(s):
 Release date: December 2012
 Publisher(s): O'Reilly Media, Inc.
 ISBN: 9781449316952
You might also like
book
R Graphics Cookbook, 2nd Edition
This O’Reilly cookbook provides more than 150 recipes to help scientists, engineers, programmers, and data analysts …
book
R Cookbook
With more than 200 practical recipes, this book helps you perform data analysis with R quickly …
book
R Graphics, 2nd Edition
Extensively updated to reflect the evolution of statistics and computing, the second edition of the bestselling …
book
R Cookbook, 2nd Edition
Perform data analysis with R quickly and efficiently with more than 275 practical recipes in this …