Displaying 5 results from an estimated 5 matches for "stringsubscript".
2008 Nov 19
1
more efficient small subsets from moderate vectors?
...m, replace=TRUE)
system.time(for(k in v) tbl[k], gcFirst=TRUE)
}
There is an abrupt performance degredation at nx=1000
> lkup(1000)
user system elapsed
0.180 0.000 0.179
> lkup(1001)
user system elapsed
2.444 0.016 2.462
This is because of the heuristic at stringSubscript.c:424, which
switches from a 'naive' nx * ns algorithm (ns is the number of
elements to be extracted, ns = 1 above) to a hash-based strategy when
nx * ns > 1.
It seems like the 'naive' algorithm takes nx * ns time, whereas the
hash-based algorithm takes C(nx) + ns, where C(nx) i...
2010 Sep 08
0
Correction to vec-subset speed patch
...39;s may be mixed with negative subscripts"));
}
}
- else return positiveSubscript(s, ns, nx);
- return R_NilValue;
+ else /* min == 0 */
+ return nonnegativeSubscript(s, ns, nx);
}
typedef SEXP (*StringEltGetter)(SEXP x, int i);
@@ -482,13 +500,14 @@
static SEXP
stringSubscript(SEXP s, int ns, int nx, SEXP names,
- StringEltGetter strg, int *stretch, Rboolean in, SEXP call)
+ StringEltGetter strg, int *stretch, SEXP call)
{
SEXP indx, indexnames;
int i, j, nnames, sub, extra;
int canstretch = *stretch;
/* product may overflow, so check factors as we...
2006 Oct 07
0
Extreme slowdown with named vectors. A bug? (PR#9280)
...release (see
> details at the end). I think the script and its comments speaks for
> itself, but the outcome is certainly not wanted.
I see a similar effect to what you're describing. I also see it in
2.3.1, so it's not a new bug.
I tracked it down to an overflow occurring in the stringSubscript
function in src/main/subscript.c: at the beginning there's a test
ns * nx > 1000
When ns and nx are both large, the product overflows and becomes
negative. I'll see if I can fix it.
Duncan Murdoch
>
> for (n in 58950:58970) {
> cat("n=", n, "\n",...
2010 Jul 15
1
Very slow subsetting by name
Hi,
I'm subsetting a named vector using character indices.
My vector of indices (or keys) is 10x longer than the vector
I'm subsetting. All my keys are distinct and only 10% of them
are valid (i.e. match a name of the vector being subsetted).
It is surprisingly slow:
x1 <- 1:1000
names(x1) <- paste("a", x1, sep="")
keys <- sample(c(names(x1),
2000 Feb 17
2
"a.matrix[a.char.matrix]<- " crashes R (PR#447)
To wit:
---
> junk <- array(3,c(10,3),dimnames=list(as.character(1:10),as.character(1:3)))
> junk[cbind(as.character(1:5),as.character(c(1,2,3,2,3)))] <- 20
>
> junk
Process R segmentation violation (core dumped) at Wed Feb 16 15:57:49
2000
---
I know that the use of a ***character*** matrix is not documented for
this context. Still, it should not crash R.
In addition to