# Run them on console!
# (functions need writing and reading access to your working directory and they also print)
avg_n <- function(.data, .col, x) {
Sys.sleep(.01)
.data |>
dplyr::pull({{ .col }}) |>
(\(m) mean(m) * x) ()
}
cp_map(.x = 1:10, .f = avg_n, .data = iris, .col = 2, name = "iris_mean")
# same function, read from cache
cp_map(.x = 1:10, .f = avg_n, .data = iris, .col = 2, name = "iris_mean")
remove_currr_cache()
Run the code above in your browser using DataLab