Displaying 20 results from an estimated 20000 matches similar to: "mean(x) != mean(rev(x)) different with x <- c(NA, NaN) for some builds"
2017 Apr 01
1
mean(x) != mean(rev(x)) different with x <- c(NA, NaN) for some builds
On Fri, Mar 31, 2017 at 10:14 PM, Prof Brian Ripley
<ripley at stats.ox.ac.uk> wrote:
> From ?NA
>
> Numerical computations using ?NA? will normally result in ?NA?: a
> possible exception is where ?NaN? is also involved, in which case
> either might result.
>
> and ?NaN
>
> Computations involving ?NaN? will return ?NaN? or perhaps ?NA?:
>
2017 Apr 01
0
mean(x) != mean(rev(x)) different with x <- c(NA, NaN) for some builds
From ?NA
Numerical computations using ?NA? will normally result in ?NA?: a
possible exception is where ?NaN? is also involved, in which case
either might result.
and ?NaN
Computations involving ?NaN? will return ?NaN? or perhaps ?NA?:
which of those two is not guaranteed and may depend on the R
platform (since compilers may re-order computations).
2018 Jul 02
2
base::mean not consistent about NA/NaN
Hi,
base::mean is not consistent in terms of handling NA/NaN.
Mean should not depend on order of its arguments while currently it is.
mean(c(NA, NaN))
#[1] NA
mean(c(NaN, NA))
#[1] NaN
I created issue so in case of no replies here status of it can be looked up
at:
https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17441
Best,
Jan
[[alternative HTML version deleted]]
2018 Jul 02
2
base::mean not consistent about NA/NaN
And for a starker example of this (documented) inconsistency,
arithmetic addition is not commutative:
> NA + NaN
[1] NA
> NaN + NA
[1] NaN
On Mon, Jul 2, 2018 at 5:32 PM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
> On 02/07/2018 11:25 AM, Jan Gorecki wrote:
>> Hi,
>> base::mean is not consistent in terms of handling NA/NaN.
>> Mean should not
2011 Apr 05
1
Inconsistency between rowMeans documentation and reality?
Dear List,
I'm not even sure this is an issue or not, but ?rowMeans has:
Value:
A numeric or complex array of suitable size, or a vector if the
result is one-dimensional. The ?dimnames? (or ?names? for a
vector result) are taken from the original array.
If there are no values in a range to be summed over (after
removing missing values with ?na.rm = TRUE?), that
2018 Jul 18
1
base::mean not consistent about NA/NaN
Yes, the performance overhead of fixing this at R level would be too
large and it would complicate the code significantly. The result of
binary operations involving NA and NaN is hardware dependent (the
propagation of NaN payload) - on some hardware, it actually works the
way we would like - NA is returned - but on some hardware you get NaN or
sometimes NA and sometimes NaN. Also there are C
2007 Sep 15
3
applying math/stat functions to rows in data frame
Hi All,
There are a variety of functions that can be applied to a variable
(column) in a data frame: mean, min, max, sd, range, IQR, etc.
I am aware of only two that work on the rows, using q1-q3 as example
variables:
rowMeans(cbind(q1,q2,q3),na.rm=T) #mean of multiple variables
rowSums (cbind(q1,q2,q3),na.rm=T) #sum of multiple variables
Can the standard column functions (listed in the
2011 Mar 25
2
two minor bugs in rowsum()
(a) In R 2.12.2 rowsum can overflow if given an integer input:
> rowsum(c(2e9L, 2e9L), c("a", "a"))
[,1]
a -294967296
> 2^32 + .Last.value
[,1]
a 4e+09
Should it be changed to coerce its x argument to numeric
(double precision) so it always returns a numeric output?
(b) When rowsum is given an x containing both NaN and NA it
appears to use the last
2014 Jun 23
2
Unfixed bugs in latest R-patched
A new version of pqR is now available at pqR-project.org, which fixes
several bugs that are also present in the latest R Core patch release
(r66002). A number of bugs found previously during pqR development
are also unfixed in the latest R Core release. Here is the list of
these bugs that are unfixed in r66002 (including documentation
deficiencies), taken from the pqR bug fix and documentation
2006 Sep 07
2
Matrix package in R-2.4.0alpha
In a newly downloaded version (today) of R-2-4-0alpha, with all packages
from CRAN also installed today, I get:
> library(Matrix)
Erro en loadNamespace(package, c(which.lib.loc, lib.loc), keep.source =
keep.source) :
in 'Matrix' methods specified for export, but none defined: BIC,
anova, coef, confint, deviance, fitted, fixef, formula, head, lmer, logLik,
mcmcsamp, plot,
2012 Jun 09
1
Inf and NA
Hi all,
I have a csv matrix "KT.csv" and it has Inf and NA
I want to calculate the mean of each row so I use
rowMeans(KT,na.rm = TRUE) but with this Inf cannot be omminted.
I?m trying to use before running rowMeans(KT,na.rm = TRUE)
KT<-range(KT,finite=TRUE)
but it doesn?t works...
Do you know a simple way to ommit Inf en the calculations?
Many thanks.
I have tried also to
2009 Dec 19
4
expand.grid game
Dear list,
In a little numbers game, I've hit a performance snag and I'm not sure
how to code this in C.
The game is the following: how many 8-digit numbers have the sum of
their digits equal to 17?
The brute-force answer could be:
maxi <- 9 # digits from 0 to 9
N <- 5 # 8 is too large
test <- 17 # for example's sake
sum(rowSums(do.call(expand.grid, c(list(1:maxi),
2018 Jan 15
1
max and pmax of NA and NaN
Dear R users,
is the following OK?
> max(NA, NaN)
[1] NA
> max(NaN, NA)
[1] NA
> pmax(NaN, NA)
[1] NA
> pmax(NA, NaN)
[1] NaN
...or is it a bug? Documentation says that NA has a higher priority over
NaN.
Best regards, Michal Burda
[[alternative HTML version deleted]]
2018 Jan 20
1
max and pmax of NA and NaN
Extremes.Rd, that documents 'max' and 'pmax', has this in "Details" section, in the paragraph before the last.
By definition the min/max of a numeric vector containing an NaN is NaN, except that the min/max of any vector containing an NA is NA even if it also contains an NaN.
------------------
>>>>> Michal Burda <michal.burda at centrum.cz>
2008 Sep 24
4
rowSums()
Say I have the following data:
testDat <- data.frame(A = c(1,NA,3), B = c(NA, NA, 3))
> testDat
A B
1 1 NA
2 NA NA
3 3 3
rowsums() with na.rm=TRUE generates the following, which is not desired:
> rowSums(testDat[, c('A', 'B')], na.rm=T)
[1] 1 0 6
rowsums() with na.rm=F generates the following, which is also not
desired:
> rowSums(testDat[, c('A',
2009 Sep 28
1
colMeans()
Hello,
I use the function rowMeans(x,na.rm=T). The result is the mean of valid
values in each row, with NA removed. A for me very important information
is, from how many valid "n" this mean has computed.
The thing is, that I apply this function on many millions of rows, so
the time it takes is multiplied by this factor! (so getting this with
"rowSums(is.na(x))" it takes
2006 Dec 10
1
Problem with loading "library(Matrix)" at Ubuntu
Dear All,
After upgrading to R-2.4.0-dapper2 (my system is ubuntu 6.06 LTS), I often
met problems when loading some packages like Matrix.
Here is the details:
> library(Matrix)
Error in loadNamespace(package, c(which.lib.loc, lib.loc), keep.source =
keep.source) :
in 'Matrix' methods specified for export, but none defined: Arith,
Math, Math2, +, %*%, Schur, as.matrix, chol,
2020 Jan 02
1
New R function is.nana = is.na & !is.nan
"nana" is meant to express "NA, really NA".
Your suggestion sounds good.
On Thu 2 Jan, 2020, 3:38 AM Pages, Herve, <hpages at fredhutch.org> wrote:
> Happy New Year everybody!
>
> The name (is.nana) doesn't make much sense to me. Can you explain it?
>
> One alternative would be to add an extra argument (e.g. 'strict') to
> is.na(). FALSE by
2010 Jan 15
2
How to delete matrix rows based on NA frequency?
Hi all,
I would like to remove rows from a matrix, based on the frequency of missing values. If there are more than 10 % missing values, the row should be deleted.
I use the following to calculate the frequencies, thereby getting a new matrix with the frequencies:
freqNA=rowMeans(is.na(exprdata))
But is there a shorter way to remove the rows based on "(1-freqNA)>0.1"
2005 May 02
4
"apply" question
Dear R users,
I??ve got a simple question but somehow I can??t find the solution:
I have a data frame with columns 1-5 containing one set of integer
values, and columns 6-10 containing another set of integer values.
Columns 6-10 contain NA??s at some places.
I now want to calculate
(1) the number of values in each row of columns 6-10 that were NA??s
(2) the sum of all values on columns 1-5