Introduction

In this chapter, we will see how to use R to make some very basic types of graphs, which can be used in almost any kind of analysis. The recipes in this chapter will give you a feel for how much can be accomplished with very little R code, which is one big reason why R is a good choice for an analysis platform.

Although the examples in this chapter are of a basic nature, we will go through all the steps to get you going from reading your data into R, making the first graph, tweaking it to suit your needs, and then saving and exporting it for use in presentations and publications.

First and foremost, you need to download and install R on your computer. All R packages are hosted on the Comprehensive R Archive Network or CRAN ( for all the three major operating systems at the following locations on the Web:

Note

Read the FAQs ( CRAN website for detailed help on installation.

Just having the basic installation of R should set you up for all the recipes in this book.

Note that the R code in this book has some comments explaining the code. Any text on a line following the # symbol is treated by R as a comment. For example, you might see something like this:

col="yellow" #Setting the color to yellow

As you can see clearly, the text after the # explains what the code is doing, that is, setting the color to yellow in this case. Comments are a way of documenting code so that others reading your code can understand it better. It also serves to help you, and you can also understand your code better when you come back to it after a long period of time. Read each line of code carefully, and look out for any comments that will help you understand the code better.