Creating line graphs

Line graphs are generally used to look at trends in data over time, so the x variable is usually time expressed as time of day, date, month, year, and so on. In this recipe, we will see how we can quickly plot such data using the same plot() function that was used in the previous recipe to make scatter plots.

Getting ready

First, we need to load the dailysales.csv example data file (you can download this file from the code download section of the book's companion website):

sales<-read.csv("dailysales.csv", header=TRUE)

As the file's name suggests, it contains daily sales data of a product. It has two columns: a date column and a sales column that shows the number of units sold.

How to do it...

Here's the code to make your first ...

Get R: Data Analysis and Visualization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.