search for: isna

Displaying 20 results from an estimated 32 matches for "isna".

Did you mean: isa
2019 Jan 21
0
orderVector1 (sort.c): Tiny improvement concerning nalast
...* /home/emilio/Descargas/R-3.5.2/src/main/sort.c 2018-11-07 00:15:02.000000000 +0100 --- /home/emilio/Descargas/R-3.5.2/src/main/sort2.c 2019-01-21 11:13:07.414332755 +0100 *************** *** 1079,1099 **** switch (TYPEOF(key)) { case LGLSXP: case INTSXP: ! for (i = 0; i < n; i++) isna[i] = (ix[i] == NA_INTEGER); ! break; case REALSXP: ! for (i = 0; i < n; i++) isna[i] = ISNAN(x[i]); ! break; case STRSXP: ! for (i = 0; i < n; i++) isna[i] = (sx[i] == NA_STRING); ! break; case CPLXSXP: ! for (i = 0; i < n; i++) isna[i] = ISNAN(cx[i]....
2009 Jul 14
1
Incorrect comment about ISNA(x) in Arith.h (PR#13826)
R-2.9.0/include/R_ext/Arith.h has: int R_IsNA(double); /* True for R's NA only */ int R_IsNaN(double); /* True for special NaN, *not* for NA */ int R_finite(double); /* True if none of NA, NaN, +/-Inf */ #define ISNA(x) R_IsNA(x) /* True for *both* NA and NaN. The first and last lines are contradictory - if R_IsNA is true only...
2008 Oct 01
0
Simulating random draws
...NA NA NA NA I'm writing a function to simulate multiple random draws from these distributions. My function currently looks something like this: simulate.unknowns <- function(pr, probs, expr, trials=1000, labels=colnames(probs)) { isNA <- is.na(pr$label) replicate(trials, { for (i in which(isNA)) { pr$label[i] <- sample(labels, 1, prob=probs[i,]) } expr(pr) }) } That works fine but that inner loop is pretty slow. Anyone have suggestions for how to improve it? In my typical case there are far more t...
2007 Mar 03
0
2 bugs in max.col() (PR#9542)
..._row_maxwithindex_double( double *x , int *nr , int *nc , int *narm , int *index , int *tiesmethod ) { int r, c, m, ntie, n_r = *nr, n_c = *nc, na_rm = *narm, ties_method = *tiesmethod; double a = 0; // to avoid uninitialized compiler warning double b, tol, small, absa; Rboolean isna; if (ties_method==1) GetRNGstate(); for (r = 0; r < n_r; r++) { /* first check row for any NAs and find the smallst entry */ small = R_PosInf; if (na_rm){ isna = TRUE; for (c = 0; c < n_c; c++){ a = x[r + c * n_r];...
2006 Dec 16
1
max.col oddity
...c 2006-12-14 15:30:56.000000000 -0500 @@ -26,13 +26,14 @@ do_rand = *ties_meth == 1; for (r = 0; r < n_r; r++) { - /* first check row for any NAs and find the largest abs(entry) */ + /* first check row for any NAs and find the largest entry */ large = 0.0; isna = FALSE; for (c = 0; c < *nc; c++) { a = matrix[r + c * n_r]; if (ISNAN(a)) { isna = TRUE; break; } - if (do_rand) large = fmax2(large, fabs(a)); + if (!R_FINITE(a)) continue; + if (do_rand) large = fmax2(large, a); } if (i...
2011 Nov 30
1
Error adding Bigmemory package
I am trying to add the bigmemory packages but I get the following error message: In file included from bigmemory.cpp:14:0: ../inst/include/bigmemory/isna.hpp: In function 'bool neginf(double)': ../inst/include/bigmemory/isna.hpp:22:57: error: 'isinf' was not declared in this scope make: *** [bigmemory.o] Error 1 ERROR: compilation failed for package 'bigmemory' * removing '/usr/local/lib/R/library/bigmemory' * restori...
1999 Apr 09
9
a strange logical bug (PR#162)
In R0.64.0, try as.numeric(is.na(c(NA,NA,1))) as.numeric(c(T,T,F)) Jim -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
2006 Dec 14
0
max.col: bug or just oddity?
...2006-12-14 15:30:56.000000000 -0500 @@ -26,13 +26,14 @@ do_rand = *ties_meth == 1; for (r = 0; r < n_r; r++) { - /* first check row for any NAs and find the largest abs(entry) */ + /* first check row for any NAs and find the largest entry */ large = 0.0; isna = FALSE; for (c = 0; c < *nc; c++) { a = matrix[r + c * n_r]; if (ISNAN(a)) { isna = TRUE; break; } - if (do_rand) large = fmax2(large, fabs(a)); + if (!R_FINITE(a)) continue; + if (do_rand) large = fmax2(large, a); }...
2009 Jun 18
2
Argument as.integer(NA) to a function C
...ot;,as.integer(boub),NAOK=TRUE) # T0=1 T1=2 T2=-2147483648 T3=4[[1]] # [1] 1 2 NA 4 --- --- In the second example, T2=-2147483648 and not NA. I check the "writing R extension", there is a part that explain that the test of NA is not the same between double and integer (NA_INTEGER, ISNA), but I did not find explanation on passing NA argument as integer. Any idea of what is wrong in my code? Christophe
2004 Sep 15
5
replacing NA's with 0 in a dataframe for specified columns
I know that there must be a cool way of doing this, but I can't think of it. Let's say I have an dataframe with NA's. > x <- data.frame(a = c(0,1,2,NA), b = c(0,NA,1,2), c = c(NA, 0, 1, 2)) > x a b c 1 0 0 NA 2 1 NA 0 3 2 1 1 4 NA 2 2 > I know it is easy to replace all the NA's with zeroes. > x[is.na(x)] <- 0 > x a b c 1 0 0 0 2 1 0 0 3 2 1
2010 Sep 08
0
Correction to vec-subset speed patch
...EXP positiveSubscript(SEXP s, int ns, int nx) +static SEXP nonnegativeSubscript(SEXP s, int ns, int nx) { SEXP indx; int i, zct = 0; @@ -433,34 +432,53 @@ static SEXP integerSubscript(SEXP s, int ns, int nx, int *stretch, SEXP call) { int i, ii, min, max, canstretch; - Rboolean isna = FALSE; + Rboolean isna; + canstretch = *stretch; *stretch = 0; - min = 0; - max = 0; + for (i = 0; i < ns; i++) { ii = INTEGER(s)[i]; - if (ii != NA_INTEGER) { - if (ii < min) + if (ii != NA_INTEGER) + break; + } + + if (i==ns) /* all NA, or n...
2020 Jan 01
2
New R function is.nana = is.na & !is.nan
...here is not that much to do. Kevin Ushey made a nice summary of current R C api in: https://stackoverflow.com/a/26262984/2490497 Pasting related part below, extra row added by me is a requested feature. +---------------------+ | C fun | NaN | NA | R fun +---------------------+ | ISNAN | t | t | is.na | R_IsNaN | t | f | is.nan | ISNA | f | t | is.na && !is.nan | R_IsNA | f | t | is.na && !is.nan +---------------------+ +---------------------+ | R fun | NaN | NA | C fun +---------------------+ | is.na |...
2017 Jan 20
1
NaN behavior of cumsum
...han the other cumulative functions wrt. NaN values: > values <- c(1,2,NaN,1) > for ( f in c(cumsum, cumprod, cummin, cummax)) print(f(values)) [1] 1 3 NA NA [1] 1 2 NaN NaN [1] 1 1 NaN NaN [1] 1 2 NaN NaN The reason is that cumsum (in cum.c:33) contains an explicit check for ISNAN. Is that intentional? IMHO, ISNA would be better (because it would make the behavior consistent with the other functions). - Lukas
2005 Jan 05
1
Standalone Mathlib, C++ and ISNAN()
...of some meaningful response and ignoring the risk of further abuse, let me try to clarify the issue here. I have re-read the 'Writing R Extensions' manual. It seems to me that it clearly says R API functions can be called from from C++ programs, and the API includes the special values ISNAN() and R_FINITE() and the missing test ISNA(). R_FINITE is no problem. It is defined as R_finite, which is declared in Rmath.h and included in libRmath. ISNAN() however is broken. In R 1.9 it was defined as R_IsNaNorNA unless IEEE_754 was defined which was not done in the standalone libRmath/...
2015 May 28
1
Fix for bug in arima function
...if(length(dx) > ncol(dxreg)) > lm(dx ~ dxreg - 1, na.action = na.omit) > else list(rank = 0L) > if(fit$rank == 0L) { > ## Degenerate model. Proceed anyway so as not to break old code > fit <- lm(x ~ xreg - 1, na.action = na.omit) > } > isna <- apply(is.na(xreg), 1, any) | is.na(x) > n.used <- sum(!isna) - length(Delta) > init0 <- c(init0, coef(fit)) That is indeed nicer ... and with logic closer to the current code. I have very slightly changed it, e.g., using anyNA(.), and tested it with some more examples......
2002 May 31
2
Matrix-like plot
Dear List, I have a 47 species * 83 samples matrix containing percentage abundance data. I have two cluster analyses one of the samples and one of the species, and have ordered the rows and columns of the species by samples matrix according to these two cluster analyses. So far so good! Now what I want to do is create a plot with the species dendrogram at the top of the plot, the samples
2015 May 21
3
Fix for bug in arima function
On 21 May 2015, at 12:49 , Martin Maechler <maechler at lynne.stat.math.ethz.ch> wrote: >>>>>> peter dalgaard <pdalgd at gmail.com> >>>>>> on Thu, 21 May 2015 11:03:05 +0200 writes: > >> On 21 May 2015, at 10:35 , Martin Maechler <maechler at lynne.stat.math.ethz.ch> wrote: > >>>> >>>> I noticed that
2017 Mar 20
2
IO error when writing to disk
...j); - if(j > 0) Rconn_printf(con, "%s", csep); + + if(j > 0) { + if(Rconn_printf(con, "%s", csep) < 0) { + error(_("IO error, cannot write table.")); + i = nr; + break; + } + } + if(isna(xj, i)) tmp = cna; else { if(!isNull(levels[j])) { @@ -1148,9 +1159,17 @@ &strBuf, sdec); } } - Rconn_printf(con, "%s", tmp); + + if(Rconn_printf(con, "%s", tmp) < 0) { + error(_("IO error, cannot write table."))...
2020 Jan 02
1
New R function is.nana = is.na & !is.nan
...YU8qcOgo&s=zFj3lh-N_YlNBRlDKeO-aTs0Bf2qtWLUHKlw_nh2Q4o&e= > > Pasting related part below, extra row added by me is a requested feature. > > > > +---------------------+ > > | C fun | NaN | NA | R fun > > +---------------------+ > > | ISNAN | t | t | is.na > > | R_IsNaN | t | f | is.nan > > | ISNA | f | t | is.na && !is.nan > > | R_IsNA | f | t | is.na && !is.nan > > +---------------------+ > > +---------------------+ > > | R fun...
2001 Dec 14
2
colSums in C
Hi, all! My project today is to write a speedy colSums(), which is a function available in S-Plus to add the columns of a matrix. Here are 4 ways to do it, with the time it took (elapsed, best of 3 trials) in both R and S-Plus: m <- matrix(1, 400, 40000) x1 <- apply(m, 2, sum) ## R=16.55 S=52.39 x2 <- as.vector(rep(1,nrow(m)) %*% m) ## R= 2.39 S= 8.52 x3 <-