♦ R Histogram
♣ About R Histogram
Histogram represents frequency of each entity(plotted on x-axis) on y-axis.Histogram groups the values of entities into continuous ranges.
R language uses the function hist() function to create a Histogram.
♣ R Histogram Syntax
Below is the representation of R Histogram Syntax.Basic Syntax
hist(v, main, xlab, xlim, ylim, breaks, col, border)
Syntax Explanation:
Parameter | Usage |
---|---|
v | vector containing numeric values used in Histogram |
main | title of the Histogram |
xlab | label for x-axis |
xlim | used to specify the range of values on the x-axis |
ylim | used to specify the range of values on the y-axis |
breaks | assigns width of each bar |
col | vector specifying color of each bar(optional) |
border | used to set border color of each bar(optional) |
♣ Example1: Plotting Data using Histogram in R
In this example: Weight(in Kgs) of 20 students in class. Example
Input:
Output: