Given
qz <- quantile(c(1,2,3,4,5,6,7,8,9,10), c(0.0, 0.2, 0.4, 0.6, 0.8, 1.0))
I want to create a vector of labels from the quantiles. C
head and tail give you the slices of the quantiles that you need to paste.
head
tail
x <- sprintf("$%.2f", qz) x ## [1] "$1.00" "$2.80" "$4.60" "$6.40" "$8.20" "$10.00" paste(head(x, -1), tail(x, -1), sep=' - ') ## [1] "$1.00 - $2.80" "$2.80 - $4.60" "$4.60 - $6.40" "$6.40 - $8.20" "$8.20 - $10.00"