Hello,
There might be another problem with some of the numbers in the example.
R uses C's double numeric type and that means that the limit is around
16 decimal digits of precision. One of the numbers has 23, so there will
allways be loss of accuracy.
a <- 234235423.56
b <-
Putting back the context:
( We are not looking at this with Nabble.)
> When estimating values each determined similarly, and in which get to them
> by algebraic operations in some cases, are rounded with 0 decimal places and
> in other cases with 2 or 3 decimal places. What is happening?
> Than
For example
> a=12344.567
> a
[1] 12344.57
> b=234.567
> b
[1] 234.567
> a=234235423.56
> a
[1] 1.11e+20
> b=111.898
> b
[1] 112
>
--
View this message in context:
http://r.789695.n4.nabble.com/Number-of-decimal-places-tp4647549p4647552.html
Sent from the R he
When estimating values each determined similarly, and in which get to them
by algebraic operations in some cases, are rounded with 0 decimal places and
in other cases with 2 or 3 decimal places. What is happening?
Thank you.
--
View this message in context:
http://r.789695.n4.nabble.com/Numbe
nteger
multiple of the resolution, that is max-min=ineger*resolution. The bbox limits
must just be rounded to the same number of digits as the resolution and include
all available values, of course.
Best regards.
> Оригинално писмо
>От: arun
>Относно: Re: [R] nu
On Mon, Jul 09, 2012 at 07:52:18AM -0500, Jim Plante wrote:
> I don't know how significant this is, but WolframAlpha's value of pi
> disagrees with R's at about the 16th decimal:
>
> Wpi->3.141592653589793238462643383279502884197169399375105
> ..^
> Rpi->3.1415926535897931159
pi,digits=36)
> b
> [1] "3.14159265358979311599796346854418516"
>
> identical(a,b)
> [1] TRUE
>
>
> identical(a,signif(pi,digits=35))
> [1] FALSE
>
>
> A.K.
>
>
>
> - Original Message -
> From: Petr Savicky
> To: r-help@
> -Original Message-
> From: Martin Ivanov
> I have the longitudes (lon) and latitudes (lat), and I have a
> resolution (r), for example r = 0.004. The bounding box must
> have the same number of digits as resolution.
Surely the issue is not the particular numeric resolution of the n
ent: Sunday, July 8, 2012 2:21 PM
Subject: Re: [R] number of decimal places in a number?
On Sat, Jul 07, 2012 at 01:12:34PM +0100, Ted Harding wrote:
> I had thought of also (as well as my numerical routing) suggesting
> a "gsub()" type solution like Joshua's below, but held ba
On Sat, Jul 07, 2012 at 11:52:35AM +0300, Martin Ivanov wrote:
> Dear R users,
>
> I need a function that gets a number and returns its number of actual decimal
> places.
> For example f(3.14) should return 2, f(3.142) should return 3, f(3.1400)
> should also return 2
> and so on. Is such funct
On Sun, Jul 08, 2012 at 11:39:22AM -0700, arun wrote:
> Hi Petr,
>
> I think sprintf and formatC are identical as it can round >22 decimal places
> as opposed to print and signif
> print(pi,digits=35)
Hi Arun:
Thank you for pointing this out. Funtion formatC()
is easier to use and uses the same
On Sat, Jul 07, 2012 at 01:12:34PM +0100, Ted Harding wrote:
> I had thought of also (as well as my numerical routing) suggesting
> a "gsub()" type solution like Joshua's below, but held back because
> the result could depend on how the number arose (keyboard input,
> file input, or from computatio
mod Ted's comments, I believe that for your situation (not too many digits
to represent, decimal point always present)
countDecDigits <-
function(x)nchar(sapply(strsplit(as.character(x),"\\."),"[",2))
is simple and should work. No need for regular expressions here.
-- Bert
On Sat, Jul 7, 2012
56237309514547462185873882845"
#using >22
x <- c("3.14", "3.142", "3.1400", "123456.123456789",
"123456789.123456789",formatC(pi,format="f",digits=35),formatC(sqrt(2),format="f",digits=50))
decimalnumcount(x)
#[1]
Dear Mr Harding,
Thank You very much for Your responsiveness.
>There would seem to be no clean general solution to this
>question. An important issue would be: What use do you
>want to put the result to?
I need this trick for the following task.
I am writing a function which has to determin
I had thought of also (as well as my numerical routing) suggesting
a "gsub()" type solution like Joshua's below, but held back because
the result could depend on how the number arose (keyboard input,
file input, or from computation within R).
However, I now also realise that (again because of bina
Hi Martin,
Ted is spot on about the binary representation. A very different
approach from his would be to convert to character and use regular
expressions:
## the example numbers in a vector
x <- c(3.14, 3.142, 3.1400, 123456.123456789, 123456789.123456789, pi, sqrt(2))
nchar(gsub("(.*\\.)|([0]
On 07-Jul-2012 08:52:35 Martin Ivanov wrote:
> Dear R users,
>
> I need a function that gets a number and returns its number of
> actual decimal places.
> For example f(3.14) should return 2, f(3.142) should return 3,
> f(3.1400) should also return 2 and so on. Is such function already
> availabl
Dear R users,
I need a function that gets a number and returns its number of actual decimal
places.
For example f(3.14) should return 2, f(3.142) should return 3, f(3.1400) should
also return 2
and so on. Is such function already available in R? If not, could you give me a
hint how to achieve
Hi,
Actually, I have two steps, the first would be to import a csv file
(read.csv). There I would need to have the same number of decimals as
there are on the original file.
Then I would run some analyses and probably export the results, e.g.
ANOVA table (write.csv). Here too I would like to h
On Jan 28, 2010, at 12:08 PM, Marc Schwartz wrote:
On Jan 28, 2010, at 10:04 AM, David Winsemius wrote:
On Jan 28, 2010, at 10:55 AM, Marc Schwartz wrote:
Ivan,
The default behavior for print()ing objects to the console in an R
session is via the use of the print.* methods. For real nu
On Jan 28, 2010, at 10:04 AM, David Winsemius wrote:
>
> On Jan 28, 2010, at 10:55 AM, Marc Schwartz wrote:
>
>> Ivan,
>>
>> The default behavior for print()ing objects to the console in an R session
>> is via the use of the print.* methods. For real numerics, print.default() is
>> used and
Ivan,
Now I'm no longer sure of just what you want. Are you concerned about
the *internal* handling of numbers by R or just about the *printing*
of numbers? As Marc has pointed out, internally R will use the full
precision that your input allows.
Perhaps you're using the F-value from the output
I guess the easiest solution for me would therefore be to set
options(digits) to a high number, and then round down if I need to!
Thanks you both for your input!
Ivan
Le 1/28/2010 17:02, Peter Ehlers a écrit :
Looks like I didn't read your post carefully enough.
If you want some sort of global
Looks like I didn't read your post carefully enough.
If you want some sort of global option to set the
display of numbers from any operation performed by R
then that's not likely to be possible without
capturing all output and formatting it yourself.
As the saying goes 'good luck with that'.
Note
On Jan 28, 2010, at 10:55 AM, Marc Schwartz wrote:
Ivan,
The default behavior for print()ing objects to the console in an R
session is via the use of the print.* methods. For real numerics,
print.default() is used and the format is based upon the number of
significant digits, not the num
First things first: thanks for your help!
I see where the confusion is. With formatC and sprintf, I have to store
the numbers I want to change into x.
I would like a way without applying a function on specific numbers
because I can shorten the numbers that way, but it won't give me more
deci
Ivan,
The default behavior for print()ing objects to the console in an R session is
via the use of the print.* methods. For real numerics, print.default() is used
and the format is based upon the number of significant digits, not the number
of decimal places. There is also an interaction with p
Ivan Calandra wrote:
It looks to me that it does more or less the same as format().
Maybe I didn't explain myself correctly then. I would like to set the
number of decimal by default, for the whole R session, like I do with
options(digits=6). Except that digits sets up the number of digits
(i
It looks to me that it does more or less the same as format().
Maybe I didn't explain myself correctly then. I would like to set the
number of decimal by default, for the whole R session, like I do with
options(digits=6). Except that digits sets up the number of digits
(including what is befor
?formatC
?sprintf
Ivan Calandra wrote:
Hi everybody,
I'm trying to set the number of decimals (i.e. the number of digits
after the "."). I looked into options but I can only set the total
number of digits, with options(digits=6). But since I have different
variables with different order of m
Hi everybody,
I'm trying to set the number of decimals (i.e. the number of digits
after the "."). I looked into options but I can only set the total
number of digits, with options(digits=6). But since I have different
variables with different order of magnitude, I would like that they're
all
32 matches
Mail list logo