R Graphics Cookbook
Welcome
Preface
0.1
Recipes
0.2
Software and Platform Notes
0.3
Conventions Used in This Book
0.4
Using Code Examples
0.5
How to Contact Us
0.6
Acknowledgments
1
R Basics
1.1
Installing a Package
1.1.1
Problem
1.1.2
Solution
1.1.3
Discussion
1.2
Loading a Package
1.2.1
Problem
1.2.2
Solution
1.2.3
Discussion
1.3
Upgrading Packages
1.3.1
Problem
1.3.2
Solution
1.3.3
Discussion
1.4
Loading a Delimited Text Data File
1.4.1
Problem
1.4.2
Solution
1.4.3
Discussion
1.4.4
See Also
1.5
Loading Data from an Excel File
1.5.1
Problem
1.5.2
Solution
1.5.3
Discussion
1.5.4
See Also
1.6
Loading Data from SPSS/SAS/Stata Files
1.6.1
Problem
1.6.2
Solution
1.6.3
Discussion
1.6.4
See Also
1.7
Chaining Functions Together With
%>%
, the Pipe Operator
1.7.1
Problem
1.7.2
Solution
1.7.3
Discussion
1.7.4
See Also
2
Quickly Exploring Data
2.1
Creating a Scatter Plot
2.1.1
Problem
2.1.2
Solution
2.1.3
See Also
2.2
Creating a Line Graph
2.2.1
Problem
2.2.2
Solution
2.2.3
See Also
2.3
Creating a Bar Graph
2.3.1
Problem
2.3.2
Solution
2.3.3
See Also
2.4
Creating a Histogram
2.4.1
Problem
2.4.2
Solution
2.4.3
See Also
2.5
Creating a Box Plot
2.5.1
Problem
2.5.2
Solution
2.5.3
See Also
2.6
Plotting a Function Curve
2.6.1
Problem
2.6.2
Solution
2.6.3
See Also
3
Bar Graphs
3.1
Making a Basic Bar Graph
3.1.1
Problem
3.1.2
Solution
3.1.3
Discussion
3.1.4
See Also
3.2
Grouping Bars Together
3.2.1
Problem
3.2.2
Solution
3.2.3
Discussion
3.2.4
See Also
3.3
Making a Bar Graph of Counts
3.3.1
Problem
3.3.2
Solution
3.3.3
Discussion
3.3.4
See Also
3.4
Using Colors in a Bar Graph
3.4.1
Problem
3.4.2
Solution
3.4.3
Discussion
3.4.4
See Also
3.5
Coloring Negative and Positive Bars Differently
3.5.1
Problem
3.5.2
Solution
3.5.3
Discussion
3.5.4
See Also
3.6
Adjusting Bar Width and Spacing
3.6.1
Problem
3.6.2
Solution
3.6.3
Discussion
3.7
Making a Stacked Bar Graph
3.7.1
Problem
3.7.2
Solution
3.7.3
Discussion
3.7.4
See Also
3.8
Making a Proportional Stacked Bar Graph
3.8.1
Problem
3.8.2
Solution
3.8.3
Discussion
3.8.4
See Also
3.9
Adding Labels to a Bar Graph
3.9.1
Problem
3.9.2
Solution
3.9.3
Discussion
3.9.4
See Also
3.10
Making a Cleveland Dot Plot
3.10.1
Problem
3.10.2
Solution
3.10.3
Discussion
3.10.4
See Also
4
Line Graphs
4.1
Making a Basic Line Graph
4.1.1
Problem
4.1.2
Solution
4.1.3
Discussion
4.1.4
See Also
4.2
Adding Points to a Line Graph
4.2.1
Problem
4.2.2
Solution
4.2.3
Discussion
4.2.4
See Also
4.3
Making a Line Graph with Multiple Lines
4.3.1
Problem
4.3.2
Solution
4.3.3
Discussion
4.4
Changing the Appearance of Lines
4.4.1
Problem
4.4.2
Solution
4.4.3
Discussion
4.4.4
See Also
4.5
Changing the Appearance of Points
4.5.1
Problem
4.5.2
Solution
4.5.3
Discussion
4.5.4
See Also
4.6
Making a Graph with a Shaded Area
4.6.1
Problem
4.6.2
Solution
4.6.3
Discussion
4.6.4
See Also
4.7
Making a Stacked Area Graph
4.7.1
Problem
4.7.2
Solution
4.7.3
Discussion
4.7.4
See Also
4.8
Making a Proportional Stacked Area Graph
4.8.1
Problem
4.8.2
Solution
4.8.3
Discussion
4.8.4
See Also
4.9
Adding a Confidence Region
4.9.1
Problem
4.9.2
Solution
4.9.3
Discussion
5
Scatter Plots
6
Summarized Data Distributions
6.1
Making a Basic Histogram
6.1.1
Problem
6.1.2
Solution
6.1.3
Discussion
7
Convert to a factor
7.0.1
See Also
7.1
Recoding a Continuous Variable to a Categorical Variable
7.1.1
Problem
7.1.2
Solution
7.1.3
Discussion
7.1.4
See Also
7.2
Calculating New Columns From Existing Columns
7.2.1
Problem
7.2.2
Solution
7.2.3
Discussion
7.2.4
See Also
7.3
Calculating New Columns by Groups
7.3.1
Problem
7.3.2
Solution
7.3.3
Discussion
7.3.4
See Also
7.4
Summarizing Data by Groups
7.4.1
Problem
7.4.2
Solution
7.4.3
Discussion
7.4.4
See Also
7.5
Summarizing Data with Standard Errors and Confidence Intervals
7.5.1
Problem
7.5.2
Solution
7.5.3
Discussion
7.5.4
See Also
7.6
Converting Data from Wide to Long
7.6.1
Problem
7.6.2
Solution
7.6.3
Discussion
7.6.4
See Also
7.7
Converting Data from Long to Wide
7.7.1
Problem
7.7.2
Solution
7.7.3
Discussion
7.7.4
See Also
7.8
Converting a Time Series Object to Times and Values
7.8.1
Problem
7.8.2
Solution
7.8.3
Discussion
7.8.4
See Also
Appendix
A
Understanding ggplot2
A.1
Background
A.2
Some Terminology and Theory
A.3
Building a Simple Plot
A.4
Printing
A.5
Stats
A.6
Themes
A.7
End
R Graphics Cookbook, 2nd edition
0.5
How to Contact Us