How would I be able to edit the r code below so that I can use the integers as the stems and tenths as the leaves in the stem-leaf plot.
data_ <- c (130.38, 129.39, 131.75, 131.32, 129.5, 132.79)
sort_data <- sort(data_)
stem(sort_data)
How would I be able to edit the r code below so that I can use the integers as the stems and tenths as the leaves in the stem-leaf plot.
data_ <- c (130.38, 129.39, 131.75, 131.32, 129.5, 132.79)
sort_data <- sort(data_)
stem(sort_data)
I'm not sure about your desired output but you may try function by rawr.
I slightly change that function to fit your purpose.
stem2 <- function(x) {
cx <- gsub('^.*\\.', ', ', as.character(sort(x)))
co <- capture.output(stem(x))
m <- gregexpr('\\d(?!.*\\|)', co, perl = TRUE)
l <- regmatches(co, m)
l <- t(do.call('rbind', lapply(l, `length<-`, max(lengths(l)))))
l[!is.na(l)] <- cx
regmatches(co, m) <- data.frame(l)
cat(gsub(' , ', ' ', co), sep = '\n')
}
stem2(data_)
The decimal point is at the |
129 | 39, 5
130 | 38
131 | 32, 75
132 | 79