Running examples in 'reproducible-Ex.R' failed
The error most likely occurred in:

> ### Name: Cache
> ### Title: Saves a wide variety function call outputs to disk and
> ###   optionally RAM, for recovery later
> ### Aliases: Cache
> 
> ### ** Examples
> 
> data.table::setDTthreads(2)
> tmpDir <- file.path(tempdir())
> opts <- options(reproducible.cachePath = tmpDir)
> 
> # Usage -- All below are equivalent; even where args are missing or provided,
> #   Cache evaluates using default values, if these are specified in formals(FUN)
> a <- list()
> b <- list(fun = rnorm)
> bbb <- 1
> ee <- new.env(parent = emptyenv())
> ee$qq <- bbb
> 
> a[[1]] <- Cache(rnorm(1)) # no evaluation prior to Cache
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Saved! Cache file: 422bae4ed2f770cc.rds; fn: rnorm
> a[[2]] <- Cache(rnorm, 1) # no evaluation prior to Cache
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: rnorm, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous rnorm call
> a[[3]] <- Cache(do.call, rnorm, list(1))
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: rnorm, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous rnorm call
> a[[4]] <- Cache(do.call(rnorm, list(1)))
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: rnorm, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous rnorm call
> a[[5]] <- Cache(do.call(b$fun, list(1)))
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: b$fun, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous b$fun call
> a[[6]] <- Cache(do.call, b$fun, list(1))
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: b$fun, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous b$fun call
> a[[7]] <- Cache(b$fun, 1)
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: b$fun, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous b$fun call
> a[[8]] <- Cache(b$fun(1))
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: $, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous $ call
> a[[10]] <- Cache(quote(rnorm(1)))
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: quote, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous quote call
> a[[11]] <- Cache(stats::rnorm(1))
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: stats::rnorm, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous stats::rnorm call
> a[[12]] <- Cache(stats::rnorm, 1)
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: stats::rnorm, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous stats::rnorm call
> a[[13]] <- Cache(rnorm(1, 0, get("bbb", inherits = FALSE)))
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: rnorm, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous rnorm call
> a[[14]] <- Cache(rnorm(1, 0, get("qq", inherits = FALSE, envir = ee)))
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: rnorm, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous rnorm call
> a[[15]] <- Cache(rnorm(1, bbb - bbb, get("bbb", inherits = FALSE)))
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: rnorm, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous rnorm call
> a[[16]] <- Cache(rnorm(sd = 1, 0, n = get("bbb", inherits = FALSE))) # change order
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: rnorm, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous rnorm call
> a[[17]] <- Cache(rnorm(1, sd = get("ee", inherits = FALSE)$qq), mean = 0)
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: rnorm, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous rnorm call
> 
> # with base pipe -- this is put in quotes ('') because R version 4.0 can't understand this
> #  if you are using R >= 4.1 or R >= 4.2 if using the _ placeholder,
> #  then you can just use pipe normally
> usingPipe1 <- "b$fun(1) |> Cache()"  # base pipe
> 
> # For long pipe, need to wrap sequence in { }, or else only last step is cached
> usingPipe2 <-
+   '{"bbb" |>
+       parse(text = _) |>
+       eval() |>
+       rnorm()} |>
+     Cache()'
> if (getRversion() >= "4.1") {
+   a[[9]] <- eval(parse(text = usingPipe1)) # recovers cached copy
+ }
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: $, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous $ call
> if (getRversion() >= "4.2") { # uses the _ placeholder; only available in R >= 4.2
+   a[[18]] <- eval(parse(text = usingPipe2)) # recovers cached copy
+ }
There is an `eval` call in a chain of calls for Cache; 
  eval is evaluated before Cache which may be undesired. 
  Perhaps use `do.call` if the evaluation should not occur prior to Cache
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: rnorm, 422bae4ed2f770cc.rds) ...
Loaded! Cached result from previous rnorm call
> 
> length(unique(a)) == 1 #  all same
[1] FALSE
> 
> ### Pipe -- have to use { } or else only final function is Cached
> if (getRversion() >= "4.1") {
+   b1a <- 'sample(1e5, 1) |> rnorm() |> Cache()'
+   b1b <- 'sample(1e5, 1) |> rnorm() |> Cache()'
+   b2a <- '{sample(1e5, 1) |> rnorm()} |> Cache()'
+   b2b <- '{sample(1e5, 1) |> rnorm()} |> Cache()'
+   b1a <- eval(parse(text = b1a))
+   b1b <- eval(parse(text = b1b))
+   b2a <- eval(parse(text = b2a))
+   b2b <- eval(parse(text = b2b))
+   all.equal(b1a, b1b) # Not TRUE because the sample is run first
+   all.equal(b2a, b2b) # TRUE because of {  }
+ }
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Saved! Cache file: d11bd9c8ba9018bd.rds; fn: rnorm
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Saved! Cache file: 402e48221b3093d3.rds; fn: rnorm
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Saved! Cache file: 65d6fc4cf6012274.rds; fn: rnorm
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: rnorm, 65d6fc4cf6012274.rds) ...
Loaded! Cached result from previous rnorm call
[1] "Attributes: < Component \".Cache\": Component \"newCache\": 1 element mismatch >"
> 
> #########################
> # Advanced examples
> #########################
> 
> # .cacheExtra -- add something to digest
> Cache(rnorm(1), .cacheExtra = "sfessee11") # adds something other than fn args
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Saved! Cache file: 15a06cafd7e0d37e.rds; fn: rnorm
[1] -0.8980367
attr(,".Cache")
attr(,".Cache")$newCache
[1] TRUE

attr(,"tags")
[1] "cacheId:15a06cafd7e0d37e"
attr(,"call")
[1] ""
> Cache(rnorm(1), .cacheExtra = "nothing") # even though fn is same, the extra is different
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Saved! Cache file: b35d37e57ba86333.rds; fn: rnorm
[1] -1.154969
attr(,".Cache")
attr(,".Cache")$newCache
[1] TRUE

attr(,"tags")
[1] "cacheId:b35d37e57ba86333"
attr(,"call")
[1] ""
> 
> # omitArgs -- remove something from digest (kind of the opposite of .cacheExtra)
> Cache(rnorm(2, sd = 1), omitArgs = "sd") # removes one or more args from cache digest
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Saved! Cache file: d1e9b95723b3afa0.rds; fn: rnorm
[1]  0.9472297 -1.0574249
attr(,".Cache")
attr(,".Cache")$newCache
[1] TRUE

attr(,"tags")
[1] "cacheId:d1e9b95723b3afa0"
attr(,"call")
[1] ""
> Cache(rnorm(2, sd = 2), omitArgs = "sd") # b/c sd is not used, this is same as previous
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Object to retrieve (fn: rnorm, d1e9b95723b3afa0.rds) ...
Loaded! Cached result from previous rnorm call
[1]  0.9472297 -1.0574249
attr(,".Cache")
attr(,".Cache")$newCache
[1] FALSE

attr(,"tags")
[1] "cacheId:d1e9b95723b3afa0"
attr(,"call")
[1] ""
> 
> # cacheId -- force the use of a digest -- can give undesired consequences
> Cache(rnorm(3), cacheId = "k323431232") # sets the cacheId for this call
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
cacheId is not same as calculated hash. Manually searching for
  cacheId:k323431232
Saved! Cache file: k323431232.rds; fn: rnorm
[1]  1.1062937 -1.7782129  0.8976231
attr(,".Cache")
attr(,".Cache")$newCache
[1] TRUE

attr(,"tags")
[1] "cacheId:k323431232"
attr(,"call")
[1] ""
> Cache(runif(14), cacheId = "k323431232") # recovers same as above, i.e, rnorm(3)
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
cacheId is not same as calculated hash. Manually searching for
  cacheId:k323431232
Object to retrieve (fn: runif, k323431232.rds) ...
Loaded! Cached result from previous runif call
[1]  1.1062937 -1.7782129  0.8976231
attr(,".Cache")
attr(,".Cache")$newCache
[1] FALSE

attr(,"tags")
[1] "cacheId:k323431232"
attr(,"call")
[1] ""
> 
> # Turn off Caching session-wide
> opts <- options(reproducible.useCache = FALSE)
> Cache(rnorm(3)) # doesn't cache
useCache is FALSE; skipping Cache on function rnorm (currently running nested
  Cache level 2)
[1]  2.02496521  0.53554150 -0.01744317
> options(opts)
> 
> # showSimilar can help with debugging why a Cache call isn't picking up a cached copy
> Cache(rnorm(4), showSimilar = TRUE) # shows that the argument `n` is different
No cachePath supplied and getOption('reproducible.cachePath') is inside a temporary directory;
  this will not persist across R sessions.
Cache of 'rnorm' differs from
the next closest cacheId(s) k323431232 of 'rnorm'
different n
Saved! Cache file: ad0ea27476c50b66.rds; fn: rnorm
[1] -0.7316185 -0.4654665 -1.9341541  0.4765088
attr(,".Cache")
attr(,".Cache")$newCache
[1] TRUE

attr(,"tags")
[1] "cacheId:ad0ea27476c50b66"
attr(,"call")
[1] ""
> 
> ###############################################
> # devMode -- enables cache database to stay
> #            small even when developing code
> ###############################################
> opt <- options("reproducible.useCache" = "devMode")
> clearCache(tmpDir, ask = FALSE)
> centralTendency <- function(x) {
+   mean(x)
+ }
> funnyData <- c(1, 1, 1, 1, 10)
> uniqueUserTags <- c("thisIsUnique", "reallyUnique")
> ranNumsB <- Cache(centralTendency, funnyData, cachePath = tmpDir,
+                   userTags = uniqueUserTags) # sets new value to Cache
Saved! Cache file: 197064fee76dde59.rds; fn: centralTendency
> showCache(tmpDir) # 1 unique cacheId -- cacheId is 71cd24ec3b0d0cac
Cache size:
Total (including Rasters): 246 bytes
Selected objects (not including Rasters): 246 bytes
             cacheId              tagKey                   tagValue
              <char>              <char>                     <char>
 1: 197064fee76dde59        thisIsUnique               thisIsUnique
 2: 197064fee76dde59        reallyUnique               reallyUnique
 3: 197064fee76dde59            function            centralTendency
 4: 197064fee76dde59               class                    numeric
 5: 197064fee76dde59         object.size                        984
 6: 197064fee76dde59            accessed 2025-12-24 19:31:02.097829
 7: 197064fee76dde59             inCloud                      FALSE
 8: 197064fee76dde59            fromDisk                      FALSE
 9: 197064fee76dde59          resultHash                           
10: 197064fee76dde59   elapsedTimeDigest           0.002948046 secs
11: 197064fee76dde59 elapsedTimeFirstRun          0.0002810955 secs
12: 197064fee76dde59      otherFunctions                           
13: 197064fee76dde59           preDigest         x:e4aa8de28dc6c1bb
14: 197064fee76dde59           preDigest      .FUN:3df5c81377ae4909
                   createdDate
                        <char>
 1: 2025-12-24 19:31:02.099479
 2: 2025-12-24 19:31:02.099479
 3: 2025-12-24 19:31:02.099479
 4: 2025-12-24 19:31:02.099479
 5: 2025-12-24 19:31:02.099479
 6: 2025-12-24 19:31:02.099479
 7: 2025-12-24 19:31:02.099479
 8: 2025-12-24 19:31:02.099479
 9: 2025-12-24 19:31:02.099479
10: 2025-12-24 19:31:02.099479
11: 2025-12-24 19:31:02.099479
12: 2025-12-24 19:31:02.099479
13: 2025-12-24 19:31:02.099479
14: 2025-12-24 19:31:02.099479
> 
> # During development, we often redefine function internals
> centralTendency <- function(x) {
+   median(x)
+ }
> # When we rerun, we don't want to keep the "old" cache because the function will
> #   never again be defined that way. Here, because of userTags being the same,
> #   it will replace the entry in the Cache, effetively overwriting it, even though
> #   it has a different cacheId
> ranNumsD <- Cache(centralTendency, funnyData, cachePath = tmpDir, userTags = uniqueUserTags)
Error in `[.data.table`(isInRepoAlt, , `:=`(iden, identical(sum(get(.cacheTableTagColName("tag")) %in%  : 
  attempt access index 4/4 in VECTOR_ELT
Calls: Cache -> devModeFn1 -> [ -> [.data.table
Execution halted