R Strip Chart
Strip Charts
A box plot shows a summary of the values: the median, the box and the whiskers. But you cannot see the values themselves.
A strip chart draws one dot for every value, along a single line. It is a good choice when you have a small set of numbers and want to see each one of them.
Use the stripchart() function to draw a strip chart:
Example
scores <- c(55, 62, 68, 70, 71, 75, 78, 80, 82, 85, 88, 91, 95)
stripchart(scores)
Result:
Each dot is one student's test score. Now you can see that the scores are spread out from 55 to 95.
Equal Values
If some values are equal, their dots are drawn on top of each other, so you cannot see how many there are.
Here, we roll a dice 15 times:
Example
rolls <- c(3, 5, 2, 6, 3, 1, 4, 6, 3, 5, 2, 6, 4, 3, 6)
stripchart(rolls)
Result:
It looks like every number came up once, but that is not true: we rolled a 3 four times.
Add method = "stack" to stack equal values on top of each other. The pch = 19 parameter draws filled dots, like in the Plot chapter:
Example
rolls <- c(3, 5, 2, 6, 3, 1, 4, 6, 3, 5, 2, 6, 4, 3, 6)
stripchart(rolls, method = "stack", pch = 19)
Result:
Now it is easy to see that 3 and 6 came up most often.
Colors and Labels
Use vertical = TRUE to draw the strip chart from bottom to top. You can also use col, main and ylab, just like in the other charts:
Example
scores <- c(55, 62, 68, 70, 71, 75, 78, 80, 82, 85, 88, 91, 95)
stripchart(scores, vertical = TRUE, pch = 19, col = "blue", main = "Test Scores", ylab = "Score")
Result:
Combine with a Box Plot
A strip chart and a box plot work well together: the box plot shows the summary, and the strip chart shows every value.
Draw the box plot first. Then draw the strip chart with add = TRUE, so the dots are added to the box plot instead of to a new chart:
Example
scores <- c(55, 62, 68, 70, 71, 75, 78, 80, 82, 85, 88, 91, 95)
boxplot(scores)
stripchart(scores, vertical = TRUE, pch = 19, col = "blue", add = TRUE)
Result: