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 8399693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:22:16+00:00 2026-06-09T21:22:16+00:00

Possible Duplicate: R round to nearest .5 or .1 How do I round to

  • 0

Possible Duplicate:
R round to nearest .5 or .1
How do I round to 1, 1.5, 2 etc instead of 1, 2 or 1.1, 1.2, 1.3 in R?

if I want to round a number with some digits after comma

a <- 2.1357

I can use

round(a, 1)

to obtain 2.1 as result.

Now let I have an array of numbers like

b <- rnorm(n = 10, mean = .5, sd = .1)
> b
[1] 0.5554950 0.4527671 0.5217543 0.6137458 0.6023219 0.7045009 0.5140363 0.5312920
[9] 0.5841152 0.4492901

If I want to round those numbers in order to make them multiples of 0.1, it’s enough to input

round(b, 1)

Now my question: what if I would like to round them in order to make the multiples of… 0.2? Or 0.3? Or 0.25… an so on?

Thanks,

  • 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-09T21:22:17+00:00Added an answer on June 9, 2026 at 9:22 pm
    a <- runif(20)  # Data
    mult <- .125    # Multiple
    mult*round(a/mult)
    

    gets you

     [1] 0.250 0.750 0.125 0.625 0.000 0.500 0.125 0.500 0.125 0.875 1.000 0.750
    [13] 0.500 0.500 0.125 0.500 0.250 0.250 0.250 0.875
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How can I format a String number to have commas and round?
Possible Duplicate: How to round a number to n decimal places in Java I
Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want
Possible Duplicate: How can I combine multiple rows into a comma-delimited list in Oracle?
Possible Duplicate: Round a double to 2 significant figures after decimal point I know
Possible Duplicate: Round a double to 2 significant figures after decimal point I have
Possible Duplicate: .Net Round Bug In C#: Math.Round(2.5) result is 2 (instead of 3)!
Possible Duplicate: Built in .Net algorithm to round value up to the nearest 10
Possible Duplicate: Round a double to 2 significant figures after decimal point The code
Possible Duplicate: Round a double to 2 significant figures after decimal point I am

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.