Skip to Content
R Programming By Example
book

R Programming By Example

by Omar Trejo Navarro
December 2017
Beginner to intermediate
470 pages
12h 29m
English
Packt Publishing
Content preview from R Programming By Example

Starting with simple applications for bar graphs

We will start with simple graphs and build our way up towards advanced graphs. The first graph we will create is a bar graph. We will plot a frequency table that shows how many sale orders we have for each QUANTITY number in our sales. To do so, we use the ggplot() function using sales as the data and setting up the aesthetics with the aes() function with QUANTITY in the x axis (the first argument).

After we create a graph base with the ggplot() function, we add layers for different objects we want to see in the graph (for example, bars, lines, and points). In this case, we add bars with the geom_bar() function. Note how this layer is added using the + (plus) sign to the graph base. After that, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Efficient R Programming

Efficient R Programming

Colin Gillespie, Robin Lovelace
R Programming

R Programming

Jared P. Lander

Publisher Resources

ISBN: 9781788292542Supplemental Content