Create a stem-and-leaf plot where the stems can be grouped by multiple values and the leaves indicate where the values are split

grouped_stem(invec, n = 2)

# S3 method for grouped_stem
print(x, ...)

Arguments

invec

The input vector. This function only works with integers.

n

The number of stem values to be grouped

x

The object to be printed.

...

Not used.

Value

A list printed with stem-and-leaf formatting

References

https://stackoverflow.com/q/62044245/1270695

See also

Author

Ananda Mahto

Examples

set.seed(1) data_pos <- sample(0:50, 100, TRUE) grouped_stem(data_pos, 2)
#> 0 to 1 | 001355555568899*02233344667789999 #> 2 to 3 | 000011222223444447788*012223345666777888889999 #> 4 to 5 | 0111123333344555677*0000
data_neg <- sample(-50:-1, 100, TRUE) grouped_stem(data_neg, 2)
#> -5 to -4 | 000*99854421100 #> -3 to -2 | 998776655422221*9997777555543332222100 #> -1 to -0 | 99877766666544443222211000*99888776555443332221111
data_pos_neg <- c(0, sample(-50:50, 100, TRUE)) grouped_stem(data_pos_neg, 3)
#> -5 to -3 | 0*997765*976665411 #> -2 to -0 | 765433221000*865544431000*97211 #> 0 to 2 | 02222556669*113446*0001111222367799 #> 3 to 5 | 0133455789*001225677899*0