Displaying 20 results from an estimated 22 matches for "aslogical".
2009 Mar 29
2
if does not covert raw to logical (PR#13630)
Full_Name: Wacek Kusnierczyk
Version: 2.8.0 and 2.10.0 r48242
OS: Ubuntu 8.04 Linux 32 bit
Submission from: (NULL) (80.202.30.36)
The following raises an error:
if (as.raw(1)) 1
# error: unimplemented type 'raw' in 'asLogical'
However, ?'if' says:
"
Arguments:
cond: A length-one logical vector that is not 'NA'. Conditions of
length greater than one are accepted with a warning, but only
the first element is used. Other types are coerced to
logical if possibl...
2009 Jan 19
1
patch for textspecial and defaultfont in xfig
...e, *paper, *family, *bg, *fg, *encoding;
- int horizontal, onefile, pagecentre;
+ int horizontal, onefile, pagecentre, defaultfont, textspecial;
double height, width, ps;
vmax = vmaxget();
@@ -7467,6 +7476,8 @@
ps = asReal(CAR(args)); args = CDR(args);
onefile = asLogical(CAR(args)); args = CDR(args);
pagecentre = asLogical(CAR(args));args = CDR(args);
+ defaultfont = asLogical(CAR(args)); args = CDR(args);
+ textspecial = asLogical(CAR(args)); args = CDR(args);
encoding = CHAR(asChar(CAR(args)));
R_GE_checkVersionOrDie(R_GE_version);
@@ -...
2019 May 01
3
anyNA() performance on vectors of POSIXct
...anyNA( unclass(x.posixct) ),
unit='ms')
static Rboolean anyNA(SEXP call, SEXP op, SEXP args, SEXP env)
{
SEXP x = CAR(args);
SEXPTYPE xT = TYPEOF(x);
Rboolean isList = (xT == VECSXP || xT == LISTSXP), recursive = FALSE;
if (isList && length(args) > 1) recursive = asLogical(CADR(args));
*if (OBJECT(x) || (isList && !recursive)) {*
SEXP e0 = PROTECT(lang2(install("is.na"), x));
SEXP e = PROTECT(lang2(install("any"), e0));
SEXP res = PROTECT(eval(e, env));
int ans = asLogical(res);
UNPROTECT(3);
return ans == 1; // s...
2006 Jan 21
1
A patch for do_sample: check replace arg
...te_hidden do_sample(SEXP call, SEXP op, SEXP args, SEXP rho)
{
- SEXP x, y, prob;
+ SEXP x, y, prob, sreplace;
int k, n, replace;
double *p;
checkArity(op, args);
n = asInteger(CAR(args)); args = CDR(args);
k = asInteger(CAR(args)); args = CDR(args);
- 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)...
2015 Jun 01
2
sum(..., na.rm=FALSE): Summing over NA_real_ values much more expensive than non-NAs for na.rm=FALSE? Hmm...
...pported by the fact that summing over 'z'
is costs half of 'y'.
Now, I *cannot* reproduce the above using the following 'inline' example:
> sum2 <- inline::cfunction(sig=c(x="double", narm="logical"), body='
double *x_ = REAL(x);
int narm_ = asLogical(narm);
int n = length(x);
double sum = 0;
for (R_xlen_t i = 0; i < n; i++) {
if (!narm_ || !ISNAN(x_[i])) sum += x_[i];
}
return ScalarReal(sum);
')
> x <- rep(0, 1e8)
> stopifnot(typeof(x) == "double")
> system.time(sum2(x, narm=FALSE))
user system elapsed...
2007 Jun 13
5
Confusion with sapply
...05-01"
"2006-06-01" "2006-07-01" "2006-08-01"
[9] "2006-09-01" "2006-10-01"
> sapply(as.vector(dc),Set2March)
Error in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3,
:
unimplemented type 'character' in 'asLogical'
>
What am I missing here? Shouldn't the function work with the sapply
working on each entry?
TIA and best,
-Tir
2024 Apr 10
1
Problem with base::order
...s, it must be length one.
> na.last=c(T,T,T),
I think this is supposed to be a scalar, no matter the sort method. At
the very least, I don't see it documented to accept a logical vector,
and the C code in both src/main/sort.c and src/main/radixsort.c treats
the argument as a scalar (using asLogical(...), not LOGICAL(...) on the
R value).
--
Best regards,
Ivan
2019 May 21
0
anyNA() performance on vectors of POSIXct
...)
>
>
>
> static Rboolean anyNA(SEXP call, SEXP op, SEXP args, SEXP env)
> {
> SEXP x = CAR(args);
> SEXPTYPE xT = TYPEOF(x);
> Rboolean isList = (xT == VECSXP || xT == LISTSXP), recursive = FALSE;
>
> if (isList && length(args) > 1) recursive = asLogical(CADR(args));
> *if (OBJECT(x) || (isList && !recursive)) {*
> SEXP e0 = PROTECT(lang2(install("is.na"), x));
> SEXP e = PROTECT(lang2(install("any"), e0));
> SEXP res = PROTECT(eval(e, env));
> int ans = asLogical(res);
> UNPROTECT...
2011 Aug 14
0
Improved version of Rprofmem
...SEXP filename, ap;
int append_mode;
checkArity(op, args);
- if (!isString(CAR(args)) || (LENGTH(CAR(args))) != 1)
+
+ ap = args;
+ if (!isString(CAR(ap)) || (LENGTH(CAR(ap))) != 1)
error(_("invalid '%s' argument"), "filename");
- append_mode = asLogical(CADR(args));
- filename = STRING_ELT(CAR(args), 0);
- threshold = REAL(CADDR(args))[0];
- if (strlen(CHAR(filename)))
- R_InitMemReporting(filename, append_mode, threshold);
+ filename = STRING_ELT(CAR(ap), 0);
+
+ ap = CDR(ap);
+ append_mode = asLogical(CAR(ap));
+
+ ap = CDR(...
2010 Jun 19
1
more powerful iconv
...|| length(CADDDR(args)) != 1)
error(_("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);...
2015 Jun 01
0
sum(..., na.rm=FALSE): Summing over NA_real_ values much more expensive than non-NAs for na.rm=FALSE? Hmm...
...#L28-L33),
whereas my sum2() code uses double. So using long double, I can
reproduce the penalty of having NA_real_ with na.rm=FALSE;
> sum3 <- inline::cfunction(sig=c(x="double", narm="logical"), body='
#define LDOUBLE long double
double *x_ = REAL(x);
int narm_ = asLogical(narm);
int n = length(x);
LDOUBLE sum = 0.0;
for (R_xlen_t i = 0; i < n; i++) {
if (!narm_ || !ISNAN(x_[i])) sum += x_[i];
}
return ScalarReal((double)sum);
')
> x <- rep(0, 1e8)
> stopifnot(typeof(x) == "double")
> system.time(sum3(x, narm=FALSE))
user sys...
2018 Dec 04
3
patch to support custom HTTP headers in download.file() and url()
...file, *mode;
int quiet, status = 0, cacheOK;
#ifdef Win32
@@ -470,10 +482,13 @@ static SEXP in_do_download(SEXP args)
if(!isString(smode) || length(smode) != 1)
error(_("invalid '%s' argument"), "mode");
mode = CHAR(STRING_ELT(smode, 0));
- cacheOK = asLogical(CAR(args));
+ cacheOK = asLogical(CAR(args)); args = CDR(args);
if(cacheOK == NA_LOGICAL)
error(_("invalid '%s' argument"), "cacheOK");
Rboolean file_URL = (strncmp(url, "file://", 7) == 0);
+ sheaders = CAR(args);
+ if(TYPEOF(sheaders) !=...
2024 Apr 10
1
Problem with base::order
Hi,
when I execute
order(letters, LETTERS, 1:26)
then everything is fine. But if I execute
order(letters, LETTERS, 1:26, na.last=c(T,T,T), decreasing=c(F,F,F))
I get the error message
Error in method != "radix" && !is.na(na.last) :
'length = 3' in constraint to 'logical(1)'
Shouldn't both give the same result?
Sigbert
2011 Oct 05
1
Moderating consequences of garbage collection when in C
...de <stdio.h>
#include "Rdefines.h"
SEXP doit(SEXP len, SEXP needed)
{
int i, n = asInteger(len);
char **s = Calloc(n, char *);
SEXP ans;
for (i = 0; i < n; ++i) {
s[i] = Calloc(80, char);
sprintf(s[i], "%78d", i);
}
if (asLogical(needed))
R_gc_needed(80 * n);
PROTECT(ans = allocVector(STRSXP, n));
for (i = 0; i < n; ++i)
SET_STRING_ELT(ans, i, mkChar(s[i]));
UNPROTECT(1);
return ans;
}
and a patch
Index: src/include/R_ext/Memory.h
=================================================...
2006 Sep 08
1
R drop behavior -- set as option in later version?
...the drop argument, if present, from the argument 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 l...
2006 Sep 08
1
R drop behavior -- set as option in later version?
...the drop argument, if present, from the argument 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 l...
2001 Feb 20
2
segfault
I've managed to trap the following segfault with xxgdb and gctorture() set. The
segfault seems to move around if gctorture() is not set, but has now occurred twice
in the same spot with it set. xxgdb gives the message
Program received signal SIGSEGV, Segmentation fault.
0x71244 in RunGenCollect (size_needed=2) at memory.c:1027
and the source listing points to FORWARD_CHILDREN(s); in the
2009 Mar 29
4
binary AND operators in R
I cannot find any R function or operator that performs a binary AND operation, as performed by Fortran built-in function "iand".
Ideally either R operator "&" or "&&" should do that. But some tests proved they do not:
> A<- 1
> B <- 2
> A
[1] 1
> B
[1] 2
> as.numeric(A&B)
[1] 1
> as.numeric(A&&B)
[1] 1
The binary
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 <-
2007 Oct 03
1
R-2.6.0 is released
...s a (provisional) new helper function that
copies character data and returns a pointer to memory
allocated using R_alloc. This can be used to create a copy of
a string stored in a CHARSXP before passing the data on to a
function that modifies its arguments.
o asLogical, asInteger, asReal and asComplex now accept STRSXP
and CHARSXP arguments, and asChar accepts CHARSXP.
o New R_GE_str2col() exported via R_ext/GraphicsEngine.h for
external device developers.
o doKeybd and doMouseevent are now exported in GraphicsDevice.h.
o R_al...