The graph
package was created to complete the Assignment
B-2, for the
STAT545b 2021 course.
graph
is a package based on ggplot2 developed to facilitate the
creation of histograms to explore the distribution of variables. The
function histogram()
displays the distribution of a single numeric
variable through a histogram.
graph
is not yet on CRAN, but you can install the package from GitHub
using the following code:
devtools::install_github("cataralina/graph")
The package have one function that displays the distribution of a single numeric variable through a histogram:
histogram()
You start with histogram()
, and then supply a dataset and the numeric
variable to plot. Information about the xlab title, the number of bins
and what to do with the NA is optional, but you can specify it using:
xlab = "title"
bins =
number of bins (defaults to 30) na.rm =
A logical vector indicating whether NA values should be
stripped before the computation proceeds. TRUE is the default.library(graph)
library(gapminder)
histogram(gapminder, lifeExp)
histogram(gapminder, lifeExp, xlab = "Life Expectancy")
histogram(gapminder, gdpPercap, xlab = "GDP per capita", bins = 20)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.