Skip to content

Commit

Permalink
Improve example for timing code chunk using hooks
Browse files Browse the repository at this point in the history
closes #389
  • Loading branch information
cderv committed Aug 22, 2023
1 parent ac81dd0 commit 136a927
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions 13-chunk-hooks.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ knitr::knit_hooks$set(time_it = local({
now <<- Sys.time()
} else {
# calculate the time difference after a chunk
res <- difftime(Sys.time(), now)
res <- difftime(Sys.time(), now, units = "secs")
# return a character string to show the time
paste('Time for this code chunk to run:', res)
paste('Time for this code chunk to run:',
round(res, 2), 'seconds')
}
}})
)
Expand Down

0 comments on commit 136a927

Please sign in to comment.