Book Image

Learning Shiny

By : Hernan Resnizky
Book Image

Learning Shiny

By: Hernan Resnizky

Overview of this book

Table of Contents (19 chapters)
Learning Shiny
Credits
About the Author
Acknowledgements
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Introducing R, RStudio, and Shiny
Index

The graphics package


As it was mentioned before, graphics is the most basic graphical package in R. As with any other package, it contains a wide variety of functions (all dedicated to graphics, of course) but plot() is the most important one. plot() is a special type of function called a generic function, which is a function that can receive inputs of different classes but produces different outputs according to the class of the input.

This can be simply appreciated by plotting the different variables of the iris dataset:

Variable type

Plot

If a character or factor vector is passed (such as Species from the iris dataset), a bar graph is returned:

plot(iris$Species)

If a numeric vector is passed, a dispersion graph is returned:

plot(iris$Sepal.Length)

If two numeric vectors are passed, a scatterplot is returned:

plot(iris$Sepal.Length,iris$Sepal.Width)

If a numeric data frame or matrix is passed, a multiple scatterplot is created:

plot(iris)

As you might have already...