…by doing as little work as possible
February 2, 2018
Rprof
&
profvis
Reserving flights
Results took > 20 seconds!
It’s OK.
Best done casually!
Optimizing slowest thing gives highest payoff
Rprof
and profvis
Rprof
: sample what R is doing
ggplot2
, dplyr
)profvis
: visualize Rprof
outputprofvis
in actionprofvis
Demoexample_apps/profvis_demo
cran_explorer/
├── app.R
├── deps.csv
├── packages.csv
├── plot_cache.R
└── utils.R
app.R
: Shiny appdeps.csv
, packages.csv
: dataplot_cache.R
: Disk-based plot cacheutils.R
: Download, prepare .csv
filesutils.R
for downloading .csv
filesreactiveVal
s on
app.R
startupdplyr
used to search, filterggplot2
used for plotsdplyr::group_by()
group_by()
takes an existing tbl and converts it into a grouped tbl where operations are performed “by group”.
group_by()
examplefilter()
after group_by()
Slowdownfilter
applied only to mtcars
filter
applied to each groupreactive
expr | mean |
---|---|
read_csv("packages.csv") |
661.4826 |
readRDS("packages.rds") |
851.1554 |
server
function)plotCache
: read-through cache for plots