A histogram is a graphical representation that organizes a group of data points into user-specified ranges and an approximate representation of the distribution of numerical data.
In R language the histogram is built with the use of hist() function.
- v:- It is a vector containing numeric values used in the histogram.
- main:-It indicates the title of the chart.
- col:- It is used to set the color of the bars.
- border:-It is used to set the border color of each bar.
- xlab:-It is used to give a description of the x-axis.
- xlim:-It is used to specify the range of values on the x-axis.
- ylim:-It is used to specify the range of values on the y-axis.
- breaks:-It is used to mention the width of each bar.
Return: It will return the histogram.
A density plot is a representation of the distribution of a numeric variable that uses a kernel density estimate to show the probability density function of the variable. In R Language we use the density() function which helps to compute kernel density estimates. And further with its return value, is used to build the final density plot.
- x: the data from which the estimate is to be computed
It will return the kernel density.
Used dataset link:-Link
We can also create a histogram and a density plot in the same frame.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.