[R] possible error in stem() function?
Sarah Goslee
sarah.goslee at gmail.com
Mon Aug 29 22:11:59 CEST 2016
The help isn't particularly helpful, but you need to play with the
scale argument.
The range of your first dataset is long enough that you're getting
only even-numbered stems by default.
Try these:
x1 <- 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(x1, scale=1)
summary(x1)
stem(x1, scale=2)
x2 <- 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(x2, scale=1)
summary(x2)
stem(x2, scale=2)
On Mon, Aug 29, 2016 at 1:42 PM, Zibeli Aton via R-help
<r-help at r-project.org> wrote:
> 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