|
Histogram
A histogram is a graphical representation of the distribution of data. The bars can be plotted either vertically or horizontally. A simple histogram chart can be created in R with the hist function. In the example below, data from the sample "trees" dataset is used to plot a histogram of tree height. hist(NumericVector) Example: > data() >hist(trees$Height) The resulting histogram is very simple. However, users can define arguments to fully customize the appearance of the plot. Each argument is entered within the hist function and separated by a comma. When using the hist function it's often easiest to start with a standard template that lists the most common arguments with a NULL or DEFAULT value (example below). The user can then define whatever arguments they choose to customize the plot.
>hist(NumericVector, freq = NULL, right = TRUE, ylim = NULL, main = NULL, sub = NULL, xlab = NULL, ylab = NULL, density = NULL, angle = NULL, col = NULL, border = NULL, axes = TRUE) IMPORTANT NOTES: The format of the above string includes extra returns after each argument. R does not recognize extra returns in a string, the extra returns are included to make visual identification of each argument quicker and easier. Common Histogram Arguments
Definitions and examples for a few of the more common arguments are provided in the table below. View the subpages under Data Visualization > Histogram to learn more about the use of these arguments in histograms.
|