I’m still going over the details of making a box plot with just a single vector or variable of data. Many of the problems in our textbook so far give this kind of data. To use ggplot, you need to make sure your data is in a data frame. So for this exercise, I’ll make some small adjustments and put the data into a data frame. More data frame info here.
My class is already familiar with matrices and matrix multiplication from their math class but now they needed to learn about a different type of data format, a data frame. A data frame is a list of vectors of equal length but can have different types of data.
Our goal in the computer lab was to create a box plot from the data in the text book using ggplot. They quickly found out that ggplot will not produce a plot with a single vector of data since ggplot requires both an x and y variable for a box plot.
The class had to search for the solution of changing a single vector into a data frame so we could use ggplot. It only took a few minutes to find a solution at stackoverflow.
From stackoverflow, this helped get them going. Before using ggplot, I had them use R’s base graphics just so we could see the difference. Also, R’s base graphics will plot the single vector data.
Here is the data from page 66 and the box plot in base graphics. You can see it’s pretty basic. [Read more…] about Make A Box Plot with Single Column Data Using Ggplot2 Tutorial