The density plot is mostly used to compare distributions of two numeric variables or a single numeric variable over the category of other variables. In this recipe, we will produce a density plot using the ggplot2
library.
To display the density, we will recall ggplotdata
here and will use the disA
variable to display the density plot.
To create a density plot, the basic code is as follows:
ggplot(data=ggplotdata,aes(x=disA))+geom_density()
The following figure shows us the visual output of the preceding code:
18.119.143.17