I am working with the cut function to prep data for a barplot histogram but keep running into a seeming inconsistency between my labels and breaks:
Error in cu
With cut()
, 11 breaks delimit 10 levels which will require only 10 labels. The "labels/breaks length conflict"
error is telling you that the call to sprintf()
is supplying one too many labels to the labels=
argument.
In code:
breaks <- 0:10/10
dat <- runif(1e4)
length(breaks)
# [1] 11
length(levels(cut(breaks, sq)))
# [1] 10