search for: na_logical

Displaying 20 results from an estimated 28 matches for "na_logical".

2018 May 08
2
unlist errors on a nested list of empty lists
...e and use.names being TRUE), which returns NULL. And the problem is in the islistfactor function in src/main/apply.c, which looks like this: static Rboolean islistfactor(SEXP X) { int i, n = length(X); switch(TYPEOF(X)) { case VECSXP: case EXPRSXP: if(n == 0) return NA_LOGICAL; for(i = 0; i < LENGTH(X); i++) if(!islistfactor(VECTOR_ELT(X, i))) return FALSE; return TRUE; break; } return isFactor(X); } One of those deeply nested lists is length 0, so at the lowest level it returns NA_LOGICAL. But then it does C-style...
2012 Sep 03
1
Possible page inefficiency in do_matrix in array.c
In do_matrix in src/array.c there is a type switch containing : case LGLSXP : for (i = 0; i < nr; i++) for (j = 0; j < nc; j++) LOGICAL(ans)[i + j * NR] = NA_LOGICAL; That seems page inefficient, iiuc. Think it should be : case LGLSXP : for (j = 0; j < nc; j++) for (i = 0; i < nr; i++) LOGICAL(ans)[i + j * NR] = NA_LOGICAL; or more simply : case LGLSXP : for (i = 0; i < nc*nr; i++) LOGICAL(ans)[i] = NA_LOGICAL; ( with s...
2018 May 09
2
unlist errors on a nested list of empty lists
...or function in src/main/apply.c, > which looks like this: > > static Rboolean islistfactor(SEXP X) > { > ? ? ?int i, n = length(X); > > ? ? ?switch(TYPEOF(X)) { > ? ? ?case VECSXP: > ? ? ?case EXPRSXP: > ? ? ? ? ?if(n == 0) return NA_LOGICAL; > ? ? ? ? ?for(i = 0; i < LENGTH(X); i++) > ? ? ? ? ? ? ?if(!islistfactor(VECTOR_ELT(X, i))) return FALSE; > ? ? ? ? ?return TRUE; > ? ? ? ? ?break; > ? ? ?} > ? ? ?return isFactor(X); > } > > One of those deeply nested lists is...
2018 May 08
0
unlist errors on a nested list of empty lists
...t; And the problem is in the islistfactor function in src/main/apply.c, > which looks like this: > > static Rboolean islistfactor(SEXP X) > { > int i, n = length(X); > > switch(TYPEOF(X)) { > case VECSXP: > case EXPRSXP: > if(n == 0) return NA_LOGICAL; > for(i = 0; i < LENGTH(X); i++) > if(!islistfactor(VECTOR_ELT(X, i))) return FALSE; > return TRUE; > break; > } > return isFactor(X); > } > > One of those deeply nested lists is length 0, so at the lowest level it &gt...
2018 May 08
2
unlist errors on a nested list of empty lists
Reproducible example: x <- list(list(list(), list())) unlist(x) *> Error in as.character.factor(x) : malformed factor* What should happen: unlist(x) > NULL R.version platform x86_64-apple-darwin15.6.0 arch x86_64 os darwin15.6.0 system x86_64, darwin15.6.0 status major 3 minor 5.0 year 2018 month 04 day
2018 May 09
0
unlist errors on a nested list of empty lists
...hich looks like this: > > > > static Rboolean islistfactor(SEXP X) > > { > > int i, n = length(X); > > > > switch(TYPEOF(X)) { > > case VECSXP: > > case EXPRSXP: > > if(n == 0) return NA_LOGICAL; > > for(i = 0; i < LENGTH(X); i++) > > if(!islistfactor(VECTOR_ELT(X, i))) return FALSE; > > return TRUE; > > break; > > } > > return isFactor(X); > > } > > > &...
2003 Jan 29
1
The function 'any' (PR#2503)
Full_Name: Paul Louisell Version: 1.6.2 OS: Windows NT Submission from: (NULL) (192.249.47.9) There is a slight bug in the function 'any'. Given a logical vector (possibly including values of 'NA'), the default action of any should be as follows: (i) at least one value = T should return T (ii) NO values = T (a) at least one value = 'NA' should return 'NA'
2006 Jan 21
1
A patch for do_sample: check replace arg
...replace = asLogical(CAR(args)); args = CDR(args); + sreplace = CAR(args); args = CDR(args); prob = CAR(args); + if (length(sreplace) != 1) + errorcall(call, _("invalid '%s' argument"), "replace"); + replace = asLogical(sreplace); if (replace == NA_LOGICAL) errorcall(call, _("invalid '%s' argument"), "replace"); if (n == NA_INTEGER || n < 1)
2010 Jun 19
1
more powerful iconv
...rror(_("invalid '%s' argument"), "sub"); - if(STRING_ELT(CADDDR(args), 0) == NA_STRING) sub = NULL; + if(STRING_ELT(CADDDR(args), 0) == NA_STRING || isRawx) sub = NULL; else sub = translateChar(STRING_ELT(CADDDR(args), 0)); mark = asLogical(CAD4R(args)); if(mark == NA_LOGICAL) @@ -584,7 +585,7 @@ PROTECT(ans = duplicate(x)); R_AllocStringBuffer(0, &cbuff); /* 0 -> default */ for(i = 0; i < LENGTH(x); i++) { - si = STRING_ELT(x, i); + si = isRawx ? x : STRING_ELT(x, i); top_of_loop: inbuf = CHAR(si); inb = LENGTH(si); outbuf = cbuff...
2006 Sep 08
1
R drop behavior -- set as option in later version?
...ent list. The object being subsetted must be the first argument. */ static void ExtractDropArg(SEXP el, int *drop) { SEXP last = el; for (el = CDR(el); el != R_NilValue; el = CDR(el)) { if(TAG(el) == R_DropSymbol) { *drop = asLogical(CAR(el)); if (*drop == NA_LOGICAL) *drop = 1; SETCDR(last, CDR(el)); } else last = el; } } ------------ This is not exactly the right syntax for a GetOption call, but something along the following lines should allow globally settable drop by modifying line 505: ------------ if(*drop == NA_LOGICAL...
2006 Sep 08
1
R drop behavior -- set as option in later version?
...ent list. The object being subsetted must be the first argument. */ static void ExtractDropArg(SEXP el, int *drop) { SEXP last = el; for (el = CDR(el); el != R_NilValue; el = CDR(el)) { if(TAG(el) == R_DropSymbol) { *drop = asLogical(CAR(el)); if (*drop == NA_LOGICAL) *drop = 1; SETCDR(last, CDR(el)); } else last = el; } } ------------ This is not exactly the right syntax for a GetOption call, but something along the following lines should allow globally settable drop by modifying line 505: ------------ if(*drop == NA_LOGICAL...
2017 Mar 03
2
Control statements with condition with greater than one should give error (not just warning) [PATCH]
...quot;, "help.try.all.packages", "htmlhelp", "HTTPUserAgent", Index: src/main/eval.c =================================================================== --- src/main/eval.c (revision 72298) +++ src/main/eval.c (working copy) @@ -1851,9 +1851,13 @@ Rboolean cond = NA_LOGICAL; if (length(s) > 1) { + int check = asInteger(GetOption1(install("check.condition"))); PROTECT(s); /* needed as per PR#15990. call gets protected by warningcall() */ - warningcall(call, - _("the condition has length > 1 and only the first element will be used")...
2023 Nov 07
1
c(NA, 0+1i) not the same as c(as.complex(NA), 0+1i)?
...han the present discussion) to see what exactly c() is doing in this case: https://github.com/r-devel/r-svn/blob/71e7480b07767f3b7d5c45a4247959aa4d83d910/src/main/bind.c#L418-L425 And indeed! It's not "coercion" in the sense I just described... there's a branch for the 'x == NA_LOGICAL' case to _convert_ to NA_complex_. On Mon, Nov 6, 2023 at 3:08?AM Martin Maechler <maechler at stat.math.ethz.ch> wrote: > >>>>> Michael Chirico > >>>>> on Sun, 5 Nov 2023 09:41:42 -0800 writes: > > > This is another follow-up to the...
2010 Sep 08
0
Correction to vec-subset speed patch
...or extracting many rows and columns of a large array, where the improvement is by about a factor of four. Extracting many rows from one column of a matrix is sped up by about 30%. Changes unrelated to speed improvement: Fixes two latent bugs where the code incorrectly refers to NA_LOGICAL when NA_INTEGER is appropriate and where LOGICAL and INTEGER types are treated as interchangeable. These cause no problems at the moment, but would if representations were changed. patch-subscript (Formerly part of patch-vec-subset) This patch also speeds up extraction, and...
2017 Mar 03
0
Control statements with condition with greater than one should give error (not just warning) [PATCH]
...;htmlhelp", "HTTPUserAgent", > Index: src/main/eval.c > =================================================================== > --- src/main/eval.c (revision 72298) > +++ src/main/eval.c (working copy) > @@ -1851,9 +1851,13 @@ > Rboolean cond = NA_LOGICAL; > if (length(s) > 1) { > + int check = asInteger(GetOption1(install("check.condition"))); > PROTECT(s); /* needed as per PR#15990. call gets protected by > warningcall() */ > - warningcall(call, > - _("the condition has length > 1...
2023 Nov 08
1
c(NA, 0+1i) not the same as c(as.complex(NA), 0+1i)?
...> this case: > > >https://github.com/r-devel/r-svn/blob/71e7480b07767f3b7d5c45a4247959aa4d83d910/src/main/bind.c#L418-L425 > > > And indeed! It's not "coercion" in the sense I just described... there's a > > branch for the 'x == NA_LOGICAL' case to_convert_ to NA_complex_. > > Yes; "of course" ... still, I did not answer your main question, > as you did ask +/- if c() should not get an adjustment to the > new as.complex(<numeric-alike>) |--> (Re = NA, Im = 0) > behavior. > > And tha...
2023 Nov 09
1
c(NA, 0+1i) not the same as c(as.complex(NA), 0+1i)?
...>> >> >https://github.com/r-devel/r-svn/blob/71e7480b07767f3b7d5c45a4247959aa4d83d910/src/main/bind.c#L418-L425 >> >> > And indeed! It's not "coercion" in the sense I just described... there's a >> > branch for the 'x == NA_LOGICAL' case to_convert_ to NA_complex_. >> >> Yes; "of course" ... still, I did not answer your main question, >> as you did ask +/- if c() should not get an adjustment to the >> new as.complex(<numeric-alike>) |--> (Re = NA, Im = 0)...
2012 Feb 26
2
Dealing with NAs in C
Hi. I am currently converting a lot of R code to C in order to make it more efficient. A lot of the data involves NAs. As the data is mainly integers > 0, I am just setting all NAs to 0 then sending it to the C code then resetting them to NAs again after the C program is done, to be compatible with the rest of the R code. Is there a more efficient way to deal with NAs in C? I have used
2017 Mar 03
2
Control statements with condition with greater than one should give error (not just warning) [PATCH]
...rAgent", > > Index: src/main/eval.c > > =================================================================== > > --- src/main/eval.c (revision 72298) > > +++ src/main/eval.c (working copy) > > @@ -1851,9 +1851,13 @@ > > Rboolean cond = NA_LOGICAL; > > > if (length(s) > 1) { > > + int check = asInteger(GetOption1(install("check.condition"))); > > PROTECT(s); /* needed as per PR#15990. call gets protected by > > warningcall() */ > > - warningcall(call, > > - _(&qu...
2011 Aug 29
3
How to safely using OpenMP pragma inside a .C() function?
I am trying to parallelize part of a C function that is called from R (via .C) using OpenMP's "parallel for" pragma. I get mixed results: some runs finish with no problem, but some lead to R crashing after issuing a long error message involving memory violations. I found this post, which describes how a .Call() function can be made to avoid crashing R by raising the stack limit: