similar to: problem with sum function

Displaying 20 results from an estimated 10000 matches similar to: "problem with sum function"

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]]
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 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
2009 Jul 23
2
Bug in seq() (PR#13849)
Full_Name: Jeremiah Cohen Version: 2.9.0 OS: Windows XP Submission from: (NULL) (129.59.230.235) I believe there is a bug in the seq() function for certain values of the "from" argument. Here are examples: > seq(-.2, .1, .1) [1] -0.2 -0.1 0.0 0.1 > seq(-.3, .1, .1) [1] -3.000000e-01 -2.000000e-01 -1.000000e-01 5.551115e-17 1.000000e-01 > seq(-.4, .1, .1) [1] -0.4 -0.3
2006 Nov 22
3
odd behaviour of %%?
Dear R Helpers, I am trying to extract the modulus from divisions by a sequence of fractions. I noticed that %% seems to behave inconsistently (to my untutored eye), thus: > 0.1%%0.1 [1] 0 > 0.2%%0.1 [1] 0 > 0.3%%0.1 [1] 0.1 > 0.4%%0.1 [1] 0 > 0.5%%0.1 [1] 0.1 > 0.6%%0.1 [1] 0.1 > 0.7%%0.1 [1] 0.1 > 0.8%%0.1 [1] 0 > 0.9%%0.1 The modulus for 0.1, 0.2, 0.4 and 0.8 is
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
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
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]]
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:
2023 Dec 16
1
zapsmall(x) for scalar x
I was quite suprised to discover that applying `zapsmall` to a scalar value has no apparent effect. For example: > y <- 2.220446e-16 > zapsmall(y,) [1] 2.2204e-16 I was expecting zapsmall(x)` to act like > round(y, digits=getOption('digits')) [1] 0 Looking at the current source code, indicates that `zapsmall` is expecting a vector: zapsmall <- function (x, digits =
2023 Dec 17
2
[External] Re: zapsmall(x) for scalar x
I think what's been missed is that zapsmall works relative to the absolute largest value in the vector. Hence if there's only one item in the vector, it is the largest, so its not zapped. The function's raison d'etre isn't to replace absolutely small values, but small values relative to the largest. Hence a vector of similar tiny values doesn't get zapped. Maybe the line
2023 Dec 17
1
zapsmall(x) for scalar x
Zapping a vector of small numbers to zero would cause problems when printing the results of summary(). For example, if zapsmall(c(2.220446e-16, ..., 2.220446e-16)) == c(0, ..., 0) then print(summary(2.220446e-16), digits = 7) would print Min. 1st Qu. Median Mean 3rd Qu. Max. 0 0 0 0 0 0 The same problem can also appear when
2023 Dec 17
1
zapsmall(x) for scalar x
Isn?t that the correct outcome? The user can change the number of digits if they want to see small values? -- Change your thoughts and you change the world. --Dr. Norman Vincent Peale > On Dec 17, 2023, at 12:11?AM, Steve Martin <stevemartin041 at gmail.com> wrote: > > ?Zapping a vector of small numbers to zero would cause problems when > printing the results of summary().
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
2003 Oct 13
1
zapsmall with all values small (PR#4554)
Hi If all values are small, zapsmall does not zap. For example ... > zapsmall(1e-24) [1] 1e-24 > zapsmall(1e-24, digits=3) [1] 1e-24 Problem appears to be in calculation of digits ... mx <- max(abs(x[!ina])) digits = if (mx > 0) max(0, digits - log10(mx)) else digits If all values are small, mx is very small, log10(mx) is
2023 Dec 18
1
[External] Re: zapsmall(x) for scalar x
Le 17/12/2023 ? 18:26, Barry Rowlingson a ?crit?: > I think what's been missed is that zapsmall works relative to the absolute > largest value in the vector. Hence if there's only one > item in the vector, it is the largest, so its not zapped. The function's > raison d'etre isn't to replace absolutely small values, > but small values relative to the largest.
2023 Dec 19
1
[External] Re: zapsmall(x) for scalar x
>>>>> Steve Martin >>>>> on Mon, 18 Dec 2023 07:56:46 -0500 writes: > Does mFUN() really need to be a function of x and the NA values of x? I > can't think of a case where it would be used on anything but the non-NA > values of x. > I think it would be easier to specify a different mFUN() (and document this > new argument)
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]
2023 Dec 18
1
[External] Re: zapsmall(x) for scalar x
>>>>> Serguei Sokol via R-devel >>>>> on Mon, 18 Dec 2023 10:29:02 +0100 writes: > Le 17/12/2023 ? 18:26, Barry Rowlingson a ?crit?: >> I think what's been missed is that zapsmall works relative to the absolute >> largest value in the vector. Hence if there's only one >> item in the vector, it is the largest, so its
2023 Dec 18
1
[External] Re: zapsmall(x) for scalar x
Le 18/12/2023 ? 11:24, Martin Maechler a ?crit?: >>>>>> Serguei Sokol via R-devel >>>>>> on Mon, 18 Dec 2023 10:29:02 +0100 writes: > > Le 17/12/2023 ? 18:26, Barry Rowlingson a ?crit?: > >> I think what's been missed is that zapsmall works relative to the absolute > >> largest value in the vector. Hence if