Skip to Content
R Programming Fundamentals
book

R Programming Fundamentals

by Kaelen Medeiros
September 2018
Beginner
206 pages
4h 27m
English
Packt Publishing
Content preview from R Programming Fundamentals

ggplot2 Basics

To begin with, here is the exact same data, plotted both with plot() and ggplot(), respectively:

This is the built-in cars dataset, which contains only two variables, speed and dist. You can generate these plots yourself, as follows:

  • Plot 1:
plot(cars)
  • Plot 2:
library(ggplot2)ggplot(cars, aes(speed, dist)) + geom_point()

Voilà! A plot and a ggplot. Which is more aesthetically pleasing to you? Which would you rather publish on a report or your blog? The answer is probably the ggplot, if you're like most data scientists out ...

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

R Programming Fundamentals

R Programming Fundamentals

Samik Sen, Marcin Dubel
Python for Programmers

Python for Programmers

Paul Deitel, Harvey Deitel

Publisher Resources

ISBN: 9781789612998Supplemental Content