This section will review how to make basic plots using the built-in R functions and the `ggplot2`

package to plot graphics.

Basic plots in R include histograms and scatterplots. To plot a histogram, we use the `hist()`

function:

> x <- c(5, 7, 12, 15, 35, 9, 5, 17, 24, 27, 16, 32) > hist(x)

The output is shown in the following plot:

You can plot mathematical formulas with the `plot()`

function as follows:

> x <- seq(2, 25, by=1) > y <- x^2 +3 > plot(x, y)

The output is shown in the following plot:

You can graph a univariate ...

Start Free Trial

No credit card required