O'Reilly logo

R Statistical Application Development by Example Beginner's Guide by Prabhanjan Narayanachar Tattar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – the stem function in play

The R function stem from the base package and stem.leaf.backback from aplpack are fundamental for our purpose to create the stem-and-leaf plots. We will illustrate these two functions for the examples discussed earlier.

  1. As mentioned in Example 4.2.1. Octane Rating of Gasoline Blends, first create the x vector, x<-c(12,22,42,13,27,46,25,52).
  2. Obtain the stem-and-leaf plot with:
    > stem(x)
      The decimal point is 1 digit(s) to the right of the |
      1 | 23
      2 | 257
      3 | 
      4 | 26
      5 | 2

    To obtain the median from the stem display we proceed as follows. Remove one point each from either side of the display. First we remove 52 and 12, and then remove 46 and 13. The trick is to proceed until we are left with either one point, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required