When I want to estimate the running time of a R code, I use the function system.time()
.
library(dplyr)
system.time({
Titanic %>%
as.data.frame() %>%
mutate(Dataset = 1) %>%
bind_rows(as.data.frame(Titanic)) %>%
mutate_all(funs(replace_na(., NA))) %>%
filter(Dataset != 1)
})
# utilisateur système écoulé
# 0.02 0.00 0.02
Question:
Is there a way to know the running time of each operations, operations between each pipe (the mutate
, then the bind_rows
, then the filter
, etc.) without running each one by one or without writing several system.time()
?
In this example it is not useful, but sometimes I received a long script, with a long running time, and I would like to identify which operations are the lowest.
I made some research but I didn't find something useful.