Book Image

R Graph Essentials

Book Image

R Graph Essentials

Overview of this book

This book is targeted at R programmers who want to learn the graphing capabilities of R. This book will presume that you have working knowledge of R.
Table of Contents (6 chapters)
5
Index

The qplot syntax


Let's assume that your data is loaded into R and now you wish to create a graph using the qplot() command. The generic qplot syntax is as follows:

qplot(x = X1, y = X2, data = X3, color = X4, shape = X5, size = X6, geom = X7, main = "Title")

Here, X represents the variables you wish to graph and the attributes you choose for your graph. You now have either univariate (one variable) or bivariate data (two variables), and you must provide instructions through the geom argument in order to create your graph. Now, let's explore some of the arguments in the qplot syntax:

  • data: This argument refers to the dataset.

  • color: This argument maps the color scheme onto a factor or numeric variable. Note that qplot selects default colors for each level of the variable. However, you can use special syntax to set your own colors.

  • shape: This argument maps symbol shapes on to factor variables, and qplot uses different shapes for different levels of the factor variable. You can use special...