Displaying 2 results from an estimated 2 matches for "dim_r_memo".
2014 Nov 24
1
Error "promise already under evaluation ..." with function(x, dim=dim(x))
...1:(80*80), nrow=80)
> # Not "legal", because it calls .Primitive().
> dim_illegal <- base::dim
> dim_R <- function(x) {
+ ns <- getNamespace("base")
+ dim <- get("dim", envir=ns, inherits=FALSE, mode="function")
+ dim(x)
+ }
> dim_R_memoized <- local({
+ dim <- NULL
+ function(x) {
+ if (is.null(dim)) {
+ dim <<- get("dim", envir=getNamespace("base"), inherits=FALSE,
mode="function")
+ }
+ dim(x)
+ }
+ })
> stats <- microbenchmark(
+ dim(x),
+ base::dim(x)...
2014 Nov 24
0
Error "promise already under evaluation ..."
...0 1 72.941 1 1 2696 1000 a
> base::dim(x) 11549 13474 15105.950 14245 15399 60824 1000 c
> dim_1(x) 1 771 2801.544 771 1156 1806225 1000 a
> dim_R(x) 5390 6930 8077.753 7315 8085 249069 1000 b
> dim_R_memoized(x) 1156 1926 2520.119 2310 2695 73528 1000 a
> dim_R_memoized_2(x) 385 771 1089.243 771 1156 20019 1000 a
> dim_illegal(x) 0 1 161.480 1 386 2311 1000 a
> sum(x) 10395 15784 16459.454 15785 16169 114333 1000 c
&g...