Skip to content

Instantly share code, notes, and snippets.

@alekrutkowski
Created August 5, 2016 14:37
Show Gist options
  • Save alekrutkowski/1770cba4a9ecb8e2e55354bad3917914 to your computer and use it in GitHub Desktop.
Save alekrutkowski/1770cba4a9ecb8e2e55354bad3917914 to your computer and use it in GitHub Desktop.
cachedCall&Assign for
library(cacheflow) # https://github.com/alekrutkowski/cacheflow
CCA <- function(FUN,...)
## cachedCall&Assign
## A macro to avoid repetitive typing like
## myX_result <- cachedCall(myX_function, ...)
## creates and object `.myX` to avoid overwriting function `myX`
## that still may be used in the subsequent cachedCall/CCA calls
## i.e.
## CCA(myX, ...)
## is an equivalent of
## .myX <- cachedCall(myX, ...)
assign(paste0('.',deparse(substitute(FUN))),
eval(bquote(cachedCall(.(substitute(FUN)),...))),
envir=parent.frame())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment