Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying R Graphs Cookbook Second Edition
  • Table Of Contents Toc
R Graphs Cookbook Second Edition

R Graphs Cookbook Second Edition - Second Edition

By : Jaynal Abedin, Hrishi V. Mittal
4 (2)
close
close
R Graphs Cookbook Second Edition

R Graphs Cookbook Second Edition

4 (2)
By: Jaynal Abedin, Hrishi V. Mittal

Overview of this book

Targeted at those with an existing familiarity with R programming, this practical guide will appeal directly to programmers interested in learning effective data visualization techniques with R and a wide-range of its associated libraries.
Table of Contents (17 chapters)
close
close
16
Index

Creating basic scatter plots

This recipe describes how to make scatter plots using some very simple commands. We'll go from a single line of code, which makes a scatter plot from preloaded data, to a script of few lines that produces a scatter plot customized with colors, titles, and axes limits specified by us.

Getting ready

All you need to do to get started is start R. You should have the R prompt on your screen as shown in the following screenshot:

Getting ready

How to do it...

Let's use one of R's built-in datasets called cars to look at the relationship between the speed of cars and the distances taken to stop the cars (recorded in the 1920s).

To make your first scatter plot, type the following command in the R prompt:

plot(cars$dist~cars$speed)

This should bring up a window with the following graph that shows the relationship between the distance travelled by cars plotted with their speeds:

How to do it...

Now, let's tweak the graph to make it look better. Type the following code in the R prompt:

plot...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
R Graphs Cookbook Second Edition
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon