[R] possible error in stem() function?

Zibeli Aton zibeli at yahoo.com
Mon Aug 29 19:42:03 CEST 2016


Using R-3.3.1 on Linux I seem to sometimes get inaccurate stem-and-leaf plots using stem.  For example:

> x <- c(479,482,487,493,494,494,495,496,497,498,498,499,503,504,507,507,508,
+                 510,511,512,514,516,520,524,525,525,527,534,536,542,545,546,547,549,
+                 557,559,561,561,563,563,567,568,569,570,572,578,584)
> stem(x)

  The decimal point is 1 digit(s) to the right of the |

  46 | 9
  48 | 27344567889
  50 | 3477801246
  52 | 0455746
  54 | 2567979
  56 | 1133789028
  58 | 4

This plot is inaccurate since there are no values 469, 483, 484, etc. in the data.

If I remove one value from the input, then the result appears correct:

> x <- c(479,482,487,493,494,494,495,496,497,498,498,499,503,504,507,507,508,
+                 510,511,512,514,516,520,524,525,525,527,534,536,542,545,546,547,549,
+                 557,559,561,561,563,563,567,568,569,570,572,578)
> stem(x)

  The decimal point is 1 digit(s) to the right of the |

  47 | 9
  48 | 27
  49 | 344567889
  50 | 34778
  51 | 01246
  52 | 04557
  53 | 46
  54 | 25679
  55 | 79
  56 | 1133789
  57 | 028

Is there a limit to the length of the input argument, a bug in the function, or something I'm missing?

Thanks.



More information about the R-help mailing list