Boxplots are used to display distribution of a numeric variable, showing the median, quartiles, outliers and range of the data.
We can create a boxplot in R using the boxplot()
function. Here is an example:
main.r82 chars6 lines
This will create a simple boxplot of the x
variable. We can also add more options to customize the plot, such as adding a title, changing the colors, adding labels to the axis, and so on.
Here is an example of a more customized boxplot:
main.r257 chars7 lines
This creates a boxplot of the Sepal.Width
variable of the iris
dataset, grouped by Species
. We added a title, labels to the axis, we changed the colors, and enabled the notch option to display a confidence interval around the median.
gistlibby LogSnag