Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Error – replacement has [x] rows, data has [y]

You could use cut

 df$valueBin <- cut(df$value, c(-Inf, 250, 500, 1000, 2000, Inf), 
    labels=c('<=250', '250-500', '500-1,000', '1,000-2,000', '>2,000'))

data

 set.seed(24)
 df <- data.frame(value= sample(0:2500, 100, replace=TRUE))

Related Posts:

  1. Remove an entire column from a data.frame in R
  2. Extract rows from R data frame based on factors (strings)
  3. Remove an entire column from a data.frame in R
  4. How can a add a row to a data frame in R?
  5. How to resolve TypeError: ‘No Numeric Data to Plot’, when numeric data exists in Python
  6. How can a add a row to a data frame in R?
  7. Error in x[j] : invalid subscript type ‘list’ while using subset in R
  8. Replacing values from a column using a condition in R
  9. variable lengths differ in R using lm
  10. number of rows of result is not a multiple of vector length (arg 2) in R
  11. How to split a data frame?
  12. Error in .subset2(x, i, exact = exact) : subscript out of bounds in R
  13. R error: “New Column would leave holes after existing columns”
  14. How to convert a table to a data frame
  15. Convert a row of a data frame to vector
Categories dataframe
While loop in batch
C# Error (Cannot Implicitly convert type ‘string’ to ‘int’)

Leave a Comment Cancel reply

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress