The major shortcoming of histograms (which we discussed in an earlier section) is that they are quite sensitive to the choice of bin margins and the number of bins. The best alternative to this is to use density plots, which are regarded as a smoothed version of a histogram. We will implement the following steps to create density plots for an iris dataset:
- Include the library within the R workspace. This is considered a mandatory step:
> library(ggplot2)
Attaching package: 'ggplot2'
The following object is masked _by_ '.GlobalEnv':
mpg
Warning message:
package 'ggplot2' was built under R version 3.5.3
Ignore the warning messages if there are any. The warning messages are usually determined with respect to system configuration.
- Have a look at the parameters to determine which plot should be used for density plot creation:
We will consider...