Skip to content

Commit

Permalink
Load packages in a non-caching chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc committed Apr 2, 2018
1 parent c8f0e35 commit f7b050b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
5 changes: 4 additions & 1 deletion wch.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ knitr::opts_chunk$set(collapse = TRUE, comment = "#>", cache = TRUE)

A number of people gave suggestions on Twitter, which I've collected here. I've benchmarked these methods with data of various sizes; scroll down to see a plot of times.

```{r define-approaches, message=FALSE}
```{r load-packages, cache = FALSE}
library(purrr)
library(dplyr)
library(tidyr)
```


```{r define-approaches, message=FALSE}
# @dattali
# Using apply (only safe when all cols are same type)
f_apply <- function(df) {
Expand Down
22 changes: 17 additions & 5 deletions wch.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,20 @@ A number of people gave suggestions on Twitter, which I've collected here. I've
```r
library(purrr)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(tidyr)
```



```r
# @dattali
# Using apply (only safe when all cols are same type)
f_apply <- function(df) {
Expand Down Expand Up @@ -133,11 +145,11 @@ knitr::kable(times)

nrow apply split_lapply lapply_row lapply_lapply pmap pmap_aslist rowwise transpose
------ ------ ------------- ----------- -------------- ------ ------------ -------- ----------
1e+01 0.001 0.000 0.000 0.000 0.002 0.000 0.042 0.000
1e+02 0.002 0.005 0.004 0.005 0.002 0.002 0.069 0.001
1e+03 0.003 0.036 0.039 0.015 0.002 0.002 0.055 0.000
1e+04 0.040 0.451 0.366 0.162 0.020 0.015 0.518 0.000
1e+05 0.534 23.915 22.106 1.847 0.217 0.201 5.398 0.000
1e+01 0.000 0.001 0.000 0.001 0.002 0.000 0.042 0
1e+02 0.001 0.005 0.006 0.005 0.001 0.001 0.056 0
1e+03 0.004 0.046 0.037 0.013 0.002 0.002 0.051 0
1e+04 0.039 0.439 0.366 0.163 0.018 0.017 0.532 0
1e+05 0.546 22.844 21.957 1.833 0.196 0.227 5.301 0


## Plot times
Expand Down
Binary file modified wch_files/figure-html/plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f7b050b

Please sign in to comment.