Re: [R] howto get significant digits for round()

From: Don MacQueen <macq_at_llnl.gov>
Date: Wed, 14 May 2008 19:53:42 -0700

I must say, I can't deduce, from what you have said, what the desired rounding rule is.

The following function does not do what you want, but maybe it's a little bit related...

> rounds

function (x, val = 1)
val * round(x/val)

If

      length = 12.2232
and

      delta-length = 0.4 (delta minus length, that is) then it must be that

      delta = 11.8232
?

12.2232 rounded to the nearest multiple of 0.4 is 12.4, not 12.2, if that's what you meant by tolerance.

-Don

At 11:31 PM +0200 5/14/08, Jonas Stein wrote:
>i have a table like this of an value and its tolerance
>
>length delta-length
>12.2232 0.4
>123.422 0.034123
>1234 12
>
>i want to round the value to the significant digits in this way:
>
>my-round(length,delta-length)
>
>12.2 , 0.4
>123.42 , 0.03
>1234 , 12
>
>how can i do this with R?
>
>please CC to email,
>thanks so far,
>
>--
>Jonas Stein <news_at_jonasstein.de>
>
>______________________________________________
>R-help_at_r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
---------------------------------
Don MacQueen
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
macq_at_llnl.gov

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 15 May 2008 - 02:57:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 15 May 2008 - 03:30:38 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive