Hist(B, col="darkgreen", ylim=c(0,10), ylab ="MY HISTOGRAM", xlab Let’s create a histogram of B in dark green and include axis labels. The trick is to transform the four variables into a single vector and make a histogram of all elements.ī <- c(A$James, A$Robert, A$David, A$Anne) ![]() Now we create a histogram from all the data in an array.Ī <- structure(list(James = c(1L, 3L, 6L, 4L, 9L), Robert = c(2L, 5L,ĤL, 5L, 12L), David = c(4L, 4L, 6L, 6L, 16L), Anne = c(3L, 5L,ĦL, 7L, 6L)). Note that R decided on an appropriate bin width. That was easy, but you need more from your histogram. Let’s start with a simple histogram using the hist() command, which is easy to use, but actually quite sophisticated.įirst, we set up a vector of numbers and then we create a histogram. It’s true, and it doesn’t have to be hard to do so. I’m sure you’ve heard that R creates beautiful graphics. This is Part 12 in my R Tutorial Series: R is Not so Hard.
0 Comments
Leave a Reply. |