Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8726855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:19:50+00:00 2026-06-13T08:19:50+00:00

I am working with the cut function to prep data for a barplot histogram

  • 0

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 cut.default(sample(1:1e+05, 500, T), breaks = sq, labels = sprintf("$%.0f", :
labels/breaks length conflict

Here is an example. I pretend that it is income data, using a sequence of 0 to $100,000 in bins of $10,000. I use the same variable to generate both breaks and labels, with minor formating on the label side. I thought they might for some reason have different lengths when comparing to a character vector, but they appear to have the same length, still.

> sq<-seq(0,100000,10000)
> cut(sample(1:100000, 500, T),breaks=sq,labels=sprintf("$%.0f",sq))
> length(sprintf("$%.0f",sq))
[1] [11]
> length(sq)
[1] [11]

EDIT:

Per @thelatemail and @Josh O’Brien’s suggestions, I changed the code to this and things are in working order.
cut(sample(1:100000, 500, T),breaks=sq,labels=sprintf("$%.0f",sq[-1]))

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:19:51+00:00Added an answer on June 13, 2026 at 8:19 am

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working with an undisclosed API, I found a function that can set the number
I'm working on a visualizer in WPF which has a function to display a
i need to cut the string approximately at 160 characters, but i want to
i'm trying for days to get this working.. but i still fail. <?php $province
Well to cut the chase, I believe that this function is causing my problem.
I am trying to get this method in a String Filter working: public function
InternalsVisibleTo is not working for my managed C++ projects, but it is for my
To cut a long story short I have the following function as part of
I'm working on some screen scraping software and have run into an issue with
Working on a small game using an HTML5 canvas, and javascript. And it's working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.