The stem
function doesn't allow several digits as leaves, as far as I can tell. So you're left with implementing it from scratch. It's not too difficult but OMG it took me such a long time to get it right... I always get confused with R weird types conversions. Anyway, here it is:
d<-strtoi(unlist(strsplit('1717 1719 1645 3739 3024 3664 3830 2991 2430 2730 3469 5086 2119 3021 3292 2844 3426 2067 3215 2767 3124 2573 2840 2449 2584 1505 1390 1645 2497 3466 3228 3192',split=' ')))
dd<-ldply(d,function(x) {data.frame(stem=x %/% 1000,leaf=sprintf("%03d",x %% 1000),stringsAsFactors=FALSE)})
for (i in 0:9) { cat(paste(i,"|","")); l<-dd[dd$stem==i,]$leaf; if (length(l)>0) {cat(sort(l))}; cat("\n") }
Result:
0 |
1 | 390 505 645 645 717 719
2 | 067 119 430 449 497 573 584 730 767 840 844 991
3 | 021 024 124 192 215 228 292 426 466 469 664 739 830
4 |
5 | 086
6 |
7 |
8 |
9 |
Remark: there's no way to do this with the stem
function simply because the purpose of a stem and leaves plot is not to display every exact value: the plot is only intended to give a "big picture" view of the distribution of the values. What matters for that is how many leaves there are for every stem, and it's enough to give a single digit since precision doesn't matter. From this point of view the stem
function does the job:
stem(d)
Or variant:
stem(d,scale=0.5)