Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
R Graph Essentials

You're reading from  R Graph Essentials

Product type Book
Published in Sep 2014
Publisher
ISBN-13 9781783554553
Pages 190 pages
Edition 1st Edition
Languages
Toc

Table of Contents (11) Chapters close

R Graph Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Base Graphics in R – One Step at a Time 2. Advanced Functions in Base Graphics 3. Mastering the qplot Function 4. Creating Graphs with ggplot Index

Mapping aesthetics to categorical variables


Now let's map both symbol size and shape to GENDER. To map symbol size to levels of a categorical variable, it is helpful to set the variable as a factor using the factor() command.

Then you set up your plot as before, but control your symbol size by adding a new layer using the plus sign: + scale_size_manual(values = c(a, b)).

The parameters a and b have a minimum value of 0 and can be as large as you like. You must select values of a and b to produce symbols of the desired size. In the next example, I have chosen symbol sizes of 5 and 7. You may select different sizes, depending on your preferences. You will gain experience very quickly and select the symbol sizes that suit your graphs best. In this case, I introduced some transparency using the alpha = I() syntax. Transparency assists in the interpretation of graphs that involve a large number of points. Enter the following syntax:

qplot(HEIGHT, WEIGHT_1, data = T, xlab = "HEIGHT (cm)", ylab...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}