Book Image

Mastering RStudio: Develop, Communicate, and Collaborate with R

4 (1)
Book Image

Mastering RStudio: Develop, Communicate, and Collaborate with R

4 (1)

Overview of this book

RStudio helps you to manage small to large projects by giving you a multi-functional integrated development environment, combined with the power and flexibility of the R programming language, which is becoming the bridge language of data science for developers and analyst worldwide. Mastering the use of RStudio will help you to solve real-world data problems. This book begins by guiding you through the installation of RStudio and explaining the user interface step by step. From there, the next logical step is to use this knowledge to improve your data analysis workflow. We will do this by building up our toolbox to create interactive reports and graphs or even web applications with Shiny. To collaborate with others, we will explore how to use Git and GitHub and how to build your own packages to ensure top quality results. Finally, we put it all together in an interactive dashboard written with R.
Table of Contents (17 chapters)
Mastering RStudio – Develop, Communicate, and Collaborate with R
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Customizing your charts


As mentioned before, one of the big advantages of ggplot2 is that you can change nearly all elements according your individual needs. In the following section, we will show you some ways to customize your visualizations.

Subsetting your data

A very handy feature of ggplot2 is the way you can subset data. Just add a subset function call to your graph to just visualize certain values. The subset you want to visualize can be set for all geoms:

ggplot(iris) %+% subset(iris,Species == "setosa") + geom_point(aes(Sepal.Length, Sepal.Width))

Otherwise, you can set it for one geom in your graph:

ggplot(iris,aes(x = Sepal.Length,y = Sepal.Width,color = Species))  + geom_point(data = subset(iris, Species %in% c("setosa","virginica")))

Setting titles

In ggplot2 it is very easy to add titles to graphs. Therefore, it provides the ggtitle function. You can just add it to your graph with the plus (+) operator:

d <- ggplot(iris, aes(Species, Sepal.Length, fill = Species)) + geom_bar(stat...