Displaying 20 results from an estimated 20000 matches similar to: "unexpected behavior using round to 2 digits on randomly generated numbers"
2010 Dec 20
6
sample() issue
> length(sample(25000, 25000*(1-.55)))
[1] 11249
> 25000*(1-.55)
[1] 11250
> length(sample(25000, 11250))
[1] 11250
> length(sample(25000, 25000*.45))
[1] 11250
So the question is, why do I get 11249 out of the first command and not
11250? I can't figure this one out.
Thanks
Cory
[[alternative HTML version deleted]]
2009 Nov 11
1
Unexpected behaviour of seq(from,to,by) (PR#14057)
Full_Name: Raimon Massanet
Version: 2.9.2
OS: Linux Ubuntu 8.10
Submission from: (NULL) (147.83.71.76)
# Hi there.
# I'm not sure whether or not this is a bug.
# But it surely is an unexpected behaviour.
V <- seq(from=0,to=1,by=0.1)
# Should generate a sequence with a step of 0.1
V==0
# [1] TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
# Ok!
V==0.1
# [1] FALSE
2007 Jan 15
1
options("digits") and print.default()
Hello everyone,
I use latex() (Hmisc) for report generation and thus have been affected by
the problem with rounding decimals described, for example, in this post:
http://thread.gmane.org/gmane.comp.lang.r.general/73287/focus=73287
In short, numbers often are printed with 15 or so decimals even if there
far less significant digits. The problem has been confirmed by Frank
Harrell and Thomas
2009 Mar 16
4
Match .3 in a sequence
Hello:I am trying to match the value 0.3 in the sequence seq(.2,.3). I get
> 0.3 %in% seq(from=.2,to=.3)
[1] FALSE
Yet
> 0.3 %in% c(.2,.3)
[1] TRUE
For arbitrary sequences, this "invisible .3" has been problematic. What is
the best way to work around this?
Thank you.
Dan
[[alternative HTML version deleted]]
2008 Jun 15
2
round(1.5) = round(2.5) = 2?
Dear R-users
with a bit of grief I had to repeat an extensive analysis because I
did not suspect (and therefore did not read the documentation) that
round was implemented as "for rounding off a 5, the IEC 60559 standard
is expected to be used, 'go to the even digit'", resulting in
round(1.5) = 2
round (2.5) = 2.
As a non-mathematician I am both puzzled and intrigued by
2013 Jan 05
3
Rounding
Hi,
Can someone explain this:
> options(digits=20)
> 1/3
[1] 0.33333333333333331483
Why the 1483 at the end?
Thanks,
David.
david-arnolds-macbook-pro-2:~ darnold$ R --version
R version 2.15.2 (2012-10-26) -- "Trick or Treat"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
--
View this
2012 Mar 01
4
problem with sum function
Hi!
I'm running R version 2.13.0 (2011-04-13)
Platform: i386-pc-mingw32/i386 (32-bit)
When i type in the command:
sum(c(-0.2, 0.8, 0.8, -3.2, 1.8))
R returns the value:
-5.551115e-17
Why doesn't R return zero in this case? There shouldn't be any rounding
error in a simple sum.
Thanks,
Mark
2012 Mar 09
4
round giving different results on Windows and Mac
Dear all,
I have been running some tests of my package RSiena on different
platforms and trying to reconcile the results.
With Mac, the commands
options(digits=4)
round(1.81652, digits=4)
print 1.817
With Windows, the same commands print 1.816
I am not bothered which answer I get, but it would be nice if they were
the same. A linux box agreed with the Mac.
Mac sessionInfo():
R version
2011 Feb 24
1
Boxplot not doing what I think it should
My box plot below is drawing its upper whisker all the way to the last point, instead of showing the point as an outlier. Am I misunderstanding, or is it a bug?
Help(boxplot) states for the parameter ?range? that ?this determines how far the plot whiskers extend out from the box. If range is positive, the whiskers extend to the most extreme data point which is no more than range times the
2009 May 13
3
simple add error (PR#13699)
Full_Name: Gostan Thierry
Version: 2.6.1 (2007-11-26)
OS: Windows XP
Submission from: (NULL) (193.49.190.42)
I cannot explain why R seems to have problems adding two big numbers.
sprintf("%f",10^4+10^19) gives "10000000000000010240.000000"
instead of "10000000000000010000.000000"
problems seems to arrive when i'm trying to add a big and a
2009 May 20
2
round function seems to produce maximum 2 decimals
I am trying to use round()to force R to display a specific number of
decimals, but it seems to display <=2 decimals no matter what I specify in
the digits argument. As an alternative I tried signif(), but it also
produces unexpected results. See example code and results below. Format()
works, but then the result no longer is numeric. Am I missing something
simple?
I am using R 2.9.0 on Windows
2011 Apr 13
1
Decimals in R/SQL
Hello,
When I am writing in sqldf or RSQLite I lose the decimals in my matrix.
The only way I can get decimals is by multiplying by 1.00000, etc. I
have tried manipulating the options, but it is only effective once I
multiply by 1.0000.
I appreciate any suggestions!
Thanks!
Example:
z <- sqldf ("select ST,
SUM(AGEP*PWGTP)*1.000000000/SUM(PWGTP)*1.00000000000000 as wgtage from
ss09
2007 Sep 16
8
Rounding up to two decimal places
Hi there
I am going to calculate VAT at one of my websites, and UK VAT is 17.5
%.
So the question is how to round up some value to two decimal points?
I often get values like 6,991..
In php I was using round function
round($price, 2)
is in ruby something similat to PHP''s round function where I could
specify number of decimal places ?
P.
2010 Nov 22
1
Problem setting the number of digits in xtable
DEar list members,
I am currently using Sweave with LaTeX which is great.
I can use xtable for formatting outp of tables but I have a problem setting the number of decimals in xtables when used with dataframe.
I have found an example on the net ith matrix and it works.
For example this works :
> > tmp <- matrix(rnorm(9), 3, 3)
> > xtmp <- xtable(tmp)
> > digits(xtmp)
2009 Jun 12
2
formatting numbers along axes as percents for perspective plot
Hello, I'm producing a 3D plot using the persp function. All my values for X, Y, and Z are decimals ranging from 0 to 1. I'd like to be able format the three axes so that the tick values are 0% 20% 40%, etc... instead of just being 0 .2 .4. Does anyone know how to do this?
Many thanks,
Steve
[[alternative HTML version deleted]]
2010 Apr 28
2
unexpected result from format(x, digits)
Is this a bug somewhere? The format function, using a specific number of digits, doesn't give sensible results:
R> set.seed(2);print(x<-rexp(5))
[1] 1.86535 0.40475 0.14665 1.73071 0.08953
R> format(x,digits=1)
[1] "1.87" "0.40" "0.15" "1.73" "0.09"
R> format(x,digits=2)
[1] "1.87" "0.40" "0.15"
2010 Feb 25
1
Zero inflation model - pscl package
I have some questions regarding Zero Inflation Poisson models.
I am using count data to analyze abundance trends of salamanders. However,
I have surveys which differ in the amount of effort (i.e. the number of
people searching and amount of time - I am using a museum database so not
all surveys were conducted by me). Therefore I need to account for the
effort. If change the count (response
2010 Jul 25
1
Discrepancy in help for object.size() and question on how to round object sizes
I think there is a discrepancy In the help for object.size().
In the usage section there is the comment:
## S3 method for class 'object_size':
while in the value section there is the text:
An object of class ?"object.size"? ...
And R itself says:
> class(object.size(letters))
[1] "object_size"
Also, I was trying to print out object sizes in Kb, but rounded to
2012 Feb 10
3
problem subsetting data frame with variable instead of constant
Hello,
I've encountered a very weird issue with the method subset(), or maybe this
is something I don't know about said method that when you're subsetting
based on the columns of a data frame you can only use constants (0.1, 2.3,
2.2) instead of variables?
Here's a look at my data frame called 'ea.cad.pwr':
*>ea.ca.pwr[1:5,]
MAF OR POWER
1 0.02 0.01 0.9999
2 0.02
2005 Aug 19
1
Summary: Unexpected result of read.dbf
Hi there,
This is summary and patch for a bug in read.dbf, demonstrating in
Message-Id: <20050818150446.697835cb.stanimura-ngs at umin.ac.jp>.
After consulting Rjpwiki, a cyber-community of R user in Japan, the
cause was found, and the patch of solution was proposed.
Overflowing occurs when we use read.dbf for reading a dbf file having
a field of longer signed integer. For example,
$