Preface |
|
ix | |
|
|
1 | (10) |
|
|
2 | (1) |
|
|
3 | (1) |
|
|
3 | (1) |
|
1.4 Loading a Delimited Text Data File |
|
|
4 | (1) |
|
1.5 Loading Data from an Excel File |
|
|
5 | (1) |
|
1.6 Loading Data from SPSS/SAS/Stata Files |
|
|
6 | (1) |
|
1.7 Chaining Functions Together with %>%, the Pipe Operator |
|
|
7 | (4) |
|
|
11 | (12) |
|
2.1 Creating a Scatter Plot |
|
|
11 | (2) |
|
2.2 Creating a Line Graph |
|
|
13 | (2) |
|
|
15 | (3) |
|
|
18 | (1) |
|
|
19 | (2) |
|
2.6 Plotting a Function Curve |
|
|
21 | (2) |
|
|
23 | (32) |
|
3.1 Making a Basic Bar Graph |
|
|
23 | (3) |
|
3.2 Grouping Bars Together |
|
|
26 | (3) |
|
3.3 Making a Bar Graph of Counts |
|
|
29 | (2) |
|
3.4 Using Colors in a Bar Graph |
|
|
31 | (2) |
|
3.5 Coloring Negative and Positive Bars Differently |
|
|
33 | (2) |
|
3.6 Adjusting Bar Width and Spacing |
|
|
35 | (2) |
|
3.7 Making a Stacked Bar Graph |
|
|
37 | (3) |
|
3.8 Making a Proportional Stacked Bar Graph |
|
|
40 | (3) |
|
3.9 Adding Labels to a Bar Graph |
|
|
43 | (6) |
|
3.10 Making a Cleveland Dot Plot |
|
|
49 | (6) |
|
|
55 | (22) |
|
4.1 Making a Basic Line Graph |
|
|
55 | (3) |
|
4.2 Adding Points to a Line Graph |
|
|
58 | (2) |
|
4.3 Making a Line Graph with Multiple Lines |
|
|
60 | (4) |
|
4.4 Changing the Appearance of Lines |
|
|
64 | (2) |
|
4.5 Changing the Appearance of Points |
|
|
66 | (2) |
|
4.6 Making a Graph with a Shaded Area |
|
|
68 | (2) |
|
4.7 Making a Stacked Area Graph |
|
|
70 | (2) |
|
4.8 Making a Proportional Stacked Area Graph |
|
|
72 | (1) |
|
4.9 Adding a Confidence Region |
|
|
73 | (4) |
|
|
77 | (50) |
|
5.1 Making a Basic Scatter Plot |
|
|
77 | (2) |
|
5.2 Grouping Points Together Using Shapes or Colors |
|
|
79 | (2) |
|
5.3 Using Different Point Shapes |
|
|
81 | (3) |
|
5.4 Mapping a Continuous Variable to Color or Size |
|
|
84 | (4) |
|
5.5 Dealing with Overplotting |
|
|
88 | (6) |
|
5.6 Adding Fitted Regression Model Lines |
|
|
94 | (5) |
|
5.7 Adding Fitted Lines from an Existing Model |
|
|
99 | (4) |
|
5.8 Adding Fitted Lines from Multiple Existing Models |
|
|
103 | (3) |
|
5.9 Adding Annotations with Model Coefficients |
|
|
106 | (3) |
|
5.10 Adding Marginal Rugs to a Scatter Plot |
|
|
109 | (2) |
|
5.11 Labeling Points in a Scatter Plot |
|
|
111 | (7) |
|
5.12 Creating a Balloon Plot |
|
|
118 | (3) |
|
5.13 Making a Scatter Plot Matrix |
|
|
121 | (6) |
|
6 Summarized Data Distributions |
|
|
127 | (34) |
|
6.1 Making a Basic Histogram |
|
|
127 | (3) |
|
6.2 Making Multiple Histograms from Grouped Data |
|
|
130 | (4) |
|
6.3 Making a Density Curve |
|
|
134 | (4) |
|
6.4 Making Multiple Density Curves from Grouped Data |
|
|
138 | (3) |
|
6.5 Making a Frequency Polygon |
|
|
141 | (1) |
|
6.6 Making a Basic Box Plot |
|
|
142 | (3) |
|
6.7 Adding Notches to a Box Plot |
|
|
145 | (1) |
|
6.8 Adding Means to a Box Plot |
|
|
146 | (1) |
|
|
147 | (4) |
|
|
151 | (3) |
|
6.11 Making Multiple Dot Plots for Grouped Data |
|
|
154 | (3) |
|
6.12 Making a Density Plot of Two-Dimensional Data |
|
|
157 | (4) |
|
|
161 | (20) |
|
7.1 Adding Text Annotations |
|
|
161 | (3) |
|
7.2 Using Mathematical Expressions in Annotations |
|
|
164 | (2) |
|
|
166 | (3) |
|
7.4 Adding Line Segments and Arrows |
|
|
169 | (2) |
|
7.5 Adding a Shaded Rectangle |
|
|
171 | (1) |
|
|
171 | (2) |
|
|
173 | (4) |
|
7.8 Adding Annotations to Individual Facets |
|
|
177 | (4) |
|
|
181 | (42) |
|
8.1 Swapping X- and Y-Axes |
|
|
181 | (2) |
|
8.2 Setting the Range of a Continuous Axis |
|
|
183 | (3) |
|
8.3 Reversing a Continuous Axis |
|
|
186 | (1) |
|
8.4 Changing the Order of Items on a Categorical Axis |
|
|
187 | (2) |
|
8.5 Setting the Scaling Ratio of the X- and Y-Axes |
|
|
189 | (2) |
|
8.6 Setting the Positions of Tick Marks |
|
|
191 | (1) |
|
8.7 Removing Tick Marks and Labels |
|
|
192 | (1) |
|
8.8 Changing the Text of Tick Labels |
|
|
193 | (3) |
|
8.9 Changing the Appearance of Tick Labels |
|
|
196 | (2) |
|
8.10 Changing the Text of Axis Labels |
|
|
198 | (1) |
|
8.11 Removing Axis Labels |
|
|
199 | (2) |
|
8.12 Changing the Appearance of Axis Labels |
|
|
201 | (1) |
|
8.13 Showing Lines Along the Axes |
|
|
202 | (2) |
|
8.14 Using a Logarithmic Axis |
|
|
204 | (5) |
|
8.15 Adding Ticks for a Logarithmic Axis |
|
|
209 | (2) |
|
8.16 Making a Circular Plot |
|
|
211 | (5) |
|
8.17 Using Dates on an Axis |
|
|
216 | (4) |
|
8.18 Using Relative Times on an Axis |
|
|
220 | (3) |
|
9 Controlling the Overall Appearance of Graphs |
|
|
223 | (16) |
|
9.1 Setting the Title of a Graph |
|
|
223 | (2) |
|
9.2 Changing the Appearance of Text |
|
|
225 | (3) |
|
|
228 | (3) |
|
9.4 Changing the Appearance of Theme Elements |
|
|
231 | (4) |
|
9.5 Creating Your Own Themes |
|
|
235 | (1) |
|
|
236 | (3) |
|
|
239 | (20) |
|
|
239 | (2) |
|
10.2 Changing the Position of a Legend |
|
|
241 | (2) |
|
10.3 Changing the Order of Items in a Legend |
|
|
243 | (3) |
|
10.4 Reversing the Order of Items in a Legend |
|
|
246 | (1) |
|
10.5 Changing a Legend Title |
|
|
247 | (2) |
|
10.6 Changing the Appearance of a Legend Title |
|
|
249 | (1) |
|
10.7 Removing a Legend Title |
|
|
250 | (1) |
|
10.8 Changing the Labels in a Legend |
|
|
251 | (4) |
|
10.9 Changing the Appearance of Legend Labels |
|
|
255 | (1) |
|
10.10 Using Labels with Multiple Lines of Text |
|
|
256 | (3) |
|
|
259 | (10) |
|
11.1 Splitting Data into Subplots with Facets |
|
|
259 | (3) |
|
11.2 Using Facets with Different Axes |
|
|
262 | (2) |
|
11.3 Changing the Text of Facet Labels |
|
|
264 | (2) |
|
11.4 Changing the Appearance of Facet Labels and Headers |
|
|
266 | (3) |
|
|
269 | (20) |
|
12.1 Setting the Colors of Objects |
|
|
269 | (1) |
|
12.2 Representing Variables with Colors |
|
|
270 | (2) |
|
12.3 Using a Colorblind-Friendly Palette |
|
|
272 | (3) |
|
12.4 Using a Different Palette for a Discrete Variable |
|
|
275 | (5) |
|
12.5 Using a Manually Defined Palette for a Discrete Variable |
|
|
280 | (3) |
|
12.6 Using a Manually Defined Palette for a Continuous Variable |
|
|
283 | (2) |
|
12.7 Coloring a Shaded Region Based on Value |
|
|
285 | (4) |
|
|
289 | (56) |
|
13.1 Making a Correlation Matrix |
|
|
289 | (4) |
|
|
293 | (2) |
|
13.3 Shading a Subregion Under a Function Curve |
|
|
295 | (2) |
|
13.4 Creating a Network Graph |
|
|
297 | (3) |
|
13.5 Using Text Labels in a Network Graph |
|
|
300 | (2) |
|
|
302 | (2) |
|
13.7 Creating a Three-Dimensional Scatter Plot |
|
|
304 | (4) |
|
13.8 Adding a Prediction Surface to a Three-Dimensional Plot |
|
|
308 | (4) |
|
13.9 Saving a Three-Dimensional Plot |
|
|
312 | (1) |
|
13.10 Animating a Three-Dimensional Plot |
|
|
313 | (1) |
|
13.11 Creating a Dendrogram |
|
|
314 | (3) |
|
13.12 Creating a Vector Field |
|
|
317 | (5) |
|
|
322 | (1) |
|
13.14 Creating a Graph of an Empirical Cumulative Distribution Function |
|
|
323 | (1) |
|
13.15 Creating a Mosaic Plot |
|
|
324 | (5) |
|
13.16 Creating a Pie Chart |
|
|
329 | (1) |
|
|
330 | (4) |
|
13.18 Creating a Choropleth Map |
|
|
334 | (5) |
|
13.19 Making a Map with a Clean Background |
|
|
339 | (1) |
|
13.20 Creating a Map from a Shapefile |
|
|
340 | (5) |
|
14 Output for Presentation |
|
|
345 | (16) |
|
14.1 Outputting to PDF Vector Files |
|
|
345 | (2) |
|
14.2 Outputting to SVG Vector Files |
|
|
347 | (1) |
|
14.3 Outputting to WMF Vector Files |
|
|
347 | (1) |
|
14.4 Editing a Vector Output File |
|
|
348 | (2) |
|
14.5 Outputting to Bitmap (PNG/TIFF) Files |
|
|
350 | (2) |
|
14.6 Using Fonts in PDF Files |
|
|
352 | (3) |
|
14.7 Using Fonts in Windows Bitmap or Screen Output |
|
|
355 | (2) |
|
14.8 Combining Several Plots into the Same Graphic |
|
|
357 | (4) |
|
15 Getting Your Data into Shape |
|
|
361 | (42) |
|
15.1 Creating a Data Frame |
|
|
362 | (1) |
|
15.2 Getting Information About a Data Structure |
|
|
363 | (2) |
|
15.3 Adding a Column to a Data Frame |
|
|
365 | (1) |
|
15.4 Deleting a Column from a Data Frame |
|
|
366 | (1) |
|
15.5 Renaming Columns in a Data Frame |
|
|
367 | (1) |
|
15.6 Reordering Columns in a Data Frame |
|
|
368 | (1) |
|
15.7 Getting a Subset of a Data Frame |
|
|
369 | (2) |
|
15.8 Changing the Order of Factor Levels |
|
|
371 | (2) |
|
15.9 Changing the Order of Factor Levels Based on Data Values |
|
|
373 | (1) |
|
15.10 Changing the Names of Factor Levels |
|
|
374 | (2) |
|
15.11 Removing Unused Levels from a Factor |
|
|
376 | (1) |
|
15.12 Changing the Names of Items in a Character Vector |
|
|
377 | (2) |
|
15.13 Recoding a Categorical Variable to Another Categorical Variable |
|
|
379 | (2) |
|
15.14 Recoding a Continuous Variable to a Categorical Variable |
|
|
381 | (1) |
|
15.15 Calculating New Columns from Existing Columns |
|
|
382 | (2) |
|
15.16 Calculating New Columns by Groups |
|
|
384 | (3) |
|
15.17 Summarizing Data by Groups |
|
|
387 | (5) |
|
15.18 Summarizing Data with Standard Errors and Confidence Intervals |
|
|
392 | (3) |
|
15.19 Converting Data from Wide to Long |
|
|
395 | (4) |
|
15.20 Converting Data from Long to Wide |
|
|
399 | (1) |
|
15.21 Converting a Time Series Object to Times and Values |
|
|
400 | (3) |
A. Understanding ggplot2 |
|
403 | (14) |
Index |
|
417 | |