Displaying 7 results from an estimated 7 matches for "hasna".
Did you mean:
hasn
2007 Aug 13
3
hasNA() / anyNA()?
Hi,
is there a hasNA() / an anyNA() function in R? Of course,
hasNA <- function(x) {
any(is.na(x));
}
would do, but that would scan all elements in 'x' and then do the
test. I'm looking for a more efficient implementation that returns
TRUE at the first NA, e.g.
hasNA <- function(x) {
for (kk...
2002 Jun 20
4
how to skip NA columns ?
R-helpers!
na.omit() can be used to remove rows with NA's
but how can I remove columns ? and remember, which columns have been removed
?
I guess I can do t(na.omit(t(o))) as shown below, but this probably creates
a lot of overhead and I do not know which columns
have been removed.
Yours,
R
> o
[,1] [,2] [,3]
[1,] 1 NA 7
[2,] 2 NA 8
[3,] 3 NA 9
>
2017 Jan 16
1
accelerating matrix multiply
...i, icc could vectorize the "nobreak" version, but the performance of it was the same as "break".
For my experiments I extracted NaN checks into a function. This was the "break" version (same performance as the current code):
static __attribute__ ((noinline)) Rboolean hasNA(double *x, int n) {
for (R_xlen_t i = 0; i < n; i++)
if (ISNAN(x[i])) return TRUE;
return FALSE;
}
And this was the "nobreak" version:
static __attribute__ ((noinline)) Rboolean hasNA(double *x, int n) {
Rboolean has = FALSE;
for (R_xlen_t i = 0; i < n; i++)...
2017 Jan 11
2
accelerating matrix multiply
> Do you have R code (including set.seed(.) if relevant) to show on how to generate
> the large square matrices you've mentioned in the beginning? So we get to some
> reproducible benchmarks?
Hi Martin,
Here is the program I used. I only generate 2 random numbers and reuse them to make the benchmark run faster. Let me know if there is something I can do to help--alternate
2017 Jan 16
0
accelerating matrix multiply
...icc could
vectorize the "nobreak" version, but the performance of it was the same
as "break".
For my experiments I extracted NaN checks into a function. This was the
"break" version (same performance as the current code):
static __attribute__ ((noinline)) Rboolean hasNA(double *x, int n) {
for (R_xlen_t i = 0; i < n; i++)
if (ISNAN(x[i])) return TRUE;
return FALSE;
}
And this was the "nobreak" version:
static __attribute__ ((noinline)) Rboolean hasNA(double *x, int n) {
Rboolean has = FALSE;
for (R_xlen_t i = 0; i < n; i++)...
2007 Aug 23
0
indexing and regression testing
..., Vec2)), length(match(c("a9","a99","a999","a9999"), iVec2)), 10, 1000)
nom denom factor
user.self 0.125 0.00022 568.1818
sys.self 0.002 0.00000 Inf
elapsed 0.126 0.00022 572.7273
>
> # and not too bad with respect to the recent hasNA() / anyNA() thread (once the index has been built)
> timefactor(any(is.na(Vec1)), any(is.na(iVec1)), 50, 50)
nom denom factor
user.self 0.0040 0.003 1.333333
sys.self 0.0004 0.000 Inf
elapsed 0.0044 0.003 1.466667
> timefactor(any(is.na(Vec2)), any(is.na(iVec2)), 50, 50...
2010 Aug 23
1
Internal state indicating if a data object has NAs/no NAs/not sure (Was: Re: Speeding up matrix multiplies)
Hi, I'm just following your messages the overhead that the code for
dealing with possible NA/NaN values brings. When I was setting up
part of the matrixStats package, I've also though about this. I was
thinking of having an additional logical argument 'hasNA'/'has.na'
where you as a user can specify whether there is NA/NaN:s or not,
allowing the code to avoid it or not. Of course, if hasNA=FALSE but
there really are NAs you'll get very funny results.
Even better would be if there would be an internal state attached to
the basic data t...