0%

Book Description

Use R's powerful graphing capabilities to design and create professional-level graphics

In Detail

R has undergone an explosion of popularity around the world. The wide range of graphs and options for creating high-impact visualizations makes R a highly effective tool for researchers, data analysts, students, and others.

This book starts with the basics of R and the principles of creating graphics, focusing on scatterplots and line graphs for research and data analysis.

After that you will learn how to include mathematical expressions on your graphs and create bar charts, histograms, boxplots, and so on using advanced functions. The book then dives deeper into shading and coloring your graphs and labeling points on graphs using the qplot function. After that you will learn how to use the ggplot package to control symbol color, size, shape, and many other attributes.

By the end of this book, you will have expert skills to create attractive and informative graphics and design professional-level graphs.

What You Will Learn

  • Understand and implement the basic graphics syntax and techniques
  • Create scatterplots and line plots, and include mathematical expressions in them
  • Include more advanced graphics and color palettes in your graph
  • Create and customize graphs using the qplot function
  • Customize the graphics, backgrounds, sizes, and colors of your graph using ggplot
  • Add layers to your graph using ggplot
  • Make publication-quality graphs using ggplot

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. R Graph Essentials
    1. Table of Contents
    2. R Graph Essentials
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Base Graphics in R – One Step at a Time
      1. Learning basic graphics techniques
      2. Creating and joining points
      3. Creating scatterplots and line plots
      4. Colors in R
      5. Passing parameter values to titles and labels
      6. Including a regression line
      7. Graphing mathematical functions
      8. R provides many options
      9. Creating graphs with several curves
      10. Customizing your axes
      11. Creating axis labels
      12. Creating multiple graphs on the same page
      13. Saving your graphs
      14. Including mathematical expressions on your plots
      15. Summary
    9. 2. Advanced Functions in Base Graphics
      1. Reading datasets into R
      2. Including a regression line and residuals
      3. A medical dataset to create graphs
      4. Creating complex multiple axes
        1. Superposing graphs
        2. Creating point labels
      5. Including a grid on your graph
      6. Shading and coloring your graph
        1. Using polygon() to shade under a normal curve
      7. Creating bar charts
        1. Including a legend
        2. Creating histograms
        3. Creating boxplots
        4. Creating pie charts
        5. Creating dotcharts
      8. R's color palettes
      9. Using smoothers on your graph
      10. Creating scatterplot matrices
        1. Writing functions to create graphs
        2. Including error bars on your graph
      11. Summary
    10. 3. Mastering the qplot Function
      1. About qplot
      2. The qplot syntax
      3. Producing scatterplots using qplot
      4. Subsetting your data before graphing
      5. Mapping aesthetics to categorical variables
      6. Controlling colors on your graph
      7. Setting up graphs as objects
      8. Creating facet plots
      9. Creating line graphs using qplot
      10. Creating multiple curves simultaneously
      11. Including smoothed curves
      12. Creating histograms with qplot
      13. Creating facet plots for histograms
      14. Creating kernel density plots
      15. Creating bar charts
      16. Creating boxplots
      17. Creating graphs with dates
      18. Summary
    11. 4. Creating Graphs with ggplot
      1. Getting started with ggplot
      2. Mapping color, shape, and size to a variable
        1. Modifying the plotting background
        2. Controlling the legend name and legend labels
        3. Modifying the x and y axes
      3. Creating attractive color schemes
      4. Creating curves for each factor level
      5. Creating histograms
      6. Creating bar charts
        1. Creating a stacked bar chart
        2. Creating a grouped bar chart
        3. Creating a faceted bar chart
      7. Creating boxplots
      8. Labeling points with text
        1. Mapping color to text
      9. Including regression lines
      10. Summary
    12. Index