Cut and labels/breaks length conflict

后端 未结 1 1195
旧时难觅i
旧时难觅i 2020-12-18 21:46

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

相关标签:
1条回答
  • 2020-12-18 22:37

    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
    
    0 讨论(0)
提交回复
热议问题