Displaying 20 results from an estimated 9000 matches similar to: "Unexpected behaviour of seq(from,to,by) (PR#14057)"
2009 Feb 24
3
invalid comparison in numeric sequence (PR#13551)
Full_Name: alex
Version: 2.8.1
OS: Ubuntu / MacOSX
Submission from: (NULL) (162.38.183.51)
> 0.6==0.6
[1] TRUE
> seq(0,1,0.1)==0.4
[1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
> seq(0,1,0.1)==0.6
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> seq(0,1,0.1)==0.8
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
2011 Mar 04
4
Floating points and floor() ?
Perhaps somebody could clarify for me if the following is a floating
point matter or otherwise, and how am I to correct for it?
> floor(100*.1)
[1] 10
> 100*(1.0-.9)
[1] 10
> floor(100*(1-0.9))
[1] 9
Thanks!
Michael
_______________________________________________________
Michael Folkes
Salmon Stock Assessment
Canadian Dept. of Fisheries & Oceans
Pacific Biological Station
2009 Jun 08
4
seq(...) strange logical value
Do you heve any idea why I get after this instruction everywhere false?
> seq (0, 1, by=0.1) == 0.3
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
But after different step it's ok:
> seq(0, 1, by=0.1) == 0.4
[1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
--
View this message in context:
2010 Mar 29
2
.Call and .C arguments
---------- Forwarded message ----------
From: Roger.Bergande at swisslife.ch
Date: Mon, 29 Mar 2010 13:51:12 +0200
Subject: .Call and .C arguments
To: bergarog at gmail.com
Dear List
My question is about .C and .Call
I was experimenting with the .C and .Call interface as I came across the
following behaviour.
The passed values are not the same in C. I 'm calling a function in C
with
2009 Aug 01
5
incorrect result (41/10-1/10)%%1 (PR#13863)
Full_Name: jan hattendorf
Version: 2.9.0
OS: XP
Submission from: (NULL) (213.3.108.185)
I get an incorrect result for
(41/10-1/10)%%1
[1] 1
The error did not occur with other numbers than 41 (1, 11, 21, 31, 51, ...)
test <- rep(NA, 1000)
for(i in 1:1000){
test[i] <- i/10-1/10
}
test[test%%1==0]
2010 Nov 28
5
unexpected behavior using round to 2 digits on randomly generated numbers
Hello!
I stumbled upon something odd that took a while to track down, and I wanted to run it by here to see if I should submit a bug report. For randomly generated numbers (from a variety of distributions) rounding them to specifically 2 digits and then multiplying them by 100 produces strange results on about 8% of cases. The problematic numbers display as I would have expected, but do not
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"
2012 Feb 02
4
The "less than" (<) operator doesnt seem to perform as expected
The example here puzzles me. It seems like the < operator doesn't work as expected.
> l <- 0.6
> u <- seq(0.4, 0.7, 0.1)
> u
[1] 0.4 0.5 0.6 0.7
> mygrid <- expand.grid("l" = l, "u" = u)
> mygrid
l u
1 0.6 0.4
2 0.6 0.5
3 0.6 0.6
4 0.6 0.7
> mygridcollapsed <- mygrid[mygrid$l < mygrid$u, ]
> mygridcollapsed
l u
3 0.6 0.6
4
2012 Jun 18
6
Inconsistency using seq
Hi all,
Is there any problem of precision when using seq?. For example:
x<- seq(0,4,0.1)
x[4]=0.3
BUT:
x[4]-0.3=5.551115e-17
It means when I use this condition within an if clause, it does not find
values with 0.3 for x[4] as it is not precisely 0.3.
Is there any bug in seq() ?
--
View this message in context: http://r.789695.n4.nabble.com/Inconsistency-using-seq-tp4633739.html
Sent from
2009 Feb 10
0
Re: form_remote_for NOT passing param: I want put and I get
Your :method is in the wrong place, it belongs after the first hash, look at the docs for the form reote for
-----Original Message-----
From: Raimon Fs <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
Sent: Tuesday, February 10, 2009 5:08 PM
To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: [Rails] Re: form_remote_for NOT passing param: I want put and I get
2007 Dec 03
2
before_filter application => exclude some other controllers
Hello again,
It''s possible to use before_filter in the application_controller, and
exclude for some methods from other controllers ?
i have a before_filter in application_controller that checks if the user
is logged, if the time hasn''t expired, ... and I want to exclude some
methods of this check, like the login. This ''login'' belongs to other
controller.
I
2007 Jun 11
2
Rounding?
I was a bit puzzed by:
> formatC(6.65,format="f",digits=1)
[1] "6.6"
So I experimented and found:
> formatC(6.6500000000000001,format="f",digits=1)
[1] "6.6"
> formatC(6.650000000000001,format="f",digits=1)
[1] "6.7"
> round(6.6500000000000001,1)
[1] 6.7
> round(6.650000000000001,1)
[1] 6.7
> version
1998 Feb 26
3
R-beta: quantile
I do:
x<-rnorm(1000)
quantile(x,c(.025,.975))
2% 98%
-1.844753 1.931762
Since I want to find a 95% confidence interval, I take the .025 and .975
quantiles. HOWEVER R says I have the 2% (not 2.5%) and 98% (not 97.5%)
points. Is it just rounding the printed 2% and 98%, or is it REALLY
finding .02 and .98 points instead of .025 and .975?
Thanks for any help.
Bill Simpson
1998 Feb 26
3
R-beta: quantile
I do:
x<-rnorm(1000)
quantile(x,c(.025,.975))
2% 98%
-1.844753 1.931762
Since I want to find a 95% confidence interval, I take the .025 and .975
quantiles. HOWEVER R says I have the 2% (not 2.5%) and 98% (not 97.5%)
points. Is it just rounding the printed 2% and 98%, or is it REALLY
finding .02 and .98 points instead of .025 and .975?
Thanks for any help.
Bill Simpson
2006 Dec 09
2
Floating point maths in R
Hi,
I am not sure if this is just me using R (R-2.3.1 and R-2.4.0) in the
wrong way or if there is a more serious bug. I was having problems
getting some calculations to add up so I ran the following tests:
> (2.34567 - 2.00000) == 0.34567 <------- should be true
[1] FALSE
> (2.23-2.00) == 0.23 <------- should be true
[1] FALSE
> 4-2==2
[1] TRUE
> (4-2)==2
[1] TRUE
>
2009 May 31
1
Bug in gmodels CrossTable()?
Is the code below showing a bug in Crosstable()? My expectation was that
the values produced by xtabs were rounded instead of truncated:
library(gmodels)
abc <- c("a", "a", "b", "b", "c", "c")
def <- c("d", "e", "f", "f", "d", "e")
wgt <- c(0.8, 0.6, 0.4, 0.5, 1.4, 1.3)
2008 Jun 06
2
Why doesn't formatC( x, digits=2, format="g") doesn't always give 2 sig figs?
Hi all
I am not a C programmer, but I am trying to understand formatC to
get consistent printing of reals to a given number of significant
digits.
Can someone please explain this to me? These first three give what
I expect on reading ?formatC:
> formatC(0.0059999, digits=2,format="fg",flag="#")
[1] "0.0060"
> formatC(0.59999,
2001 Oct 26
1
Bug or new concept in formatC?
As a sequel to my previous mail on cut, formatC does not produce
what I have been taught is significant digits:
> x <- c(1.0793,1.0796, 11.0954, 11.0736 )
> formatC(x,digits=3,format="g")
[1] "1.08" "1.08" "11.1" "11.1"
(3,3,3,3) significant digits OK
> formatC(x,digits=3,format="f")
[1] "1.079"
2012 Feb 23
3
I'm sure I'm missing something with formatC() or sprintf()
I have a four-digit string I want to convert to five digits. Take the
following frame:
zip
2108
60321
60321
22030
91910
I need row 1 to read '02108'. This forum directed me to formatC previously
(thanks!) That usually works but, for some reason, it's not in this
instance. Neither of the syntaxes below change '2108' to '02108.' The values
in cand_receipts[,1] are of
2012 Apr 03
3
Sweave xtable
Hola
Tengo un problema con Sweave y xtable, concretamente quiero cambiar el color según un criterio, creo que es más fácil explicar con los siguientes ejemplos, uno puede correr directamente porque es R, al siguiente código hay que guardarlo como Rnw, y luego puede ser corrido en R, donde seguramente al correr este se darán cuenta de mis dos problemas porque saltan al abrir el pdf que se obtiene