# NOT RUN {
# with purrr functions
long_function <- function(x, how.long=0.05){
Sys.sleep(how.long)
x
}
# }
# NOT RUN {
purrr::walk(1:100, with_progress(long_function))
purrr::walk2(1:100, 0.01, with_progress(long_function))
# }
# NOT RUN {
# with dplyr::group_map
# }
# NOT RUN {
if(require(dplyr)){
group_function <- function(x, y, how.long=0.05){
Sys.sleep(how.long)
x
}
group_map( group_by(mtcars, cyl, gear)
, with_progress(group_function, type='line')
, how.long=1/3)
group_walk( group_by_all(mtcars)
, with_progress(group_function, type='box')
, how.long=1)
}
# }
# NOT RUN {
# with standard apply functions
sapply(1:100, with_progress(long_function, type='txt'), 0.001)
# }
Run the code above in your browser using DataLab