class: center, middle, inverse, title-slide # The
drake
R package ## make for R ### Kirill Müller ### 2018-02-01, rstudio::conf(), San Diego --- background-image: url(images/humane.png) ??? From Jenny's presentation: https://github.com/jennybc/what-they-forgot --- ```r library(drake) library(tidyverse) plan <- drake_plan( raw_data = readxl::read_xlsx("raw-data.xlsx"), data = raw_data %>% mutate(Species = forcats::fct_inorder(Species)), hist = ggplot(data, aes(x = Petal.Width, fill = Species)) + geom_histogram(), model = lm(Sepal.Width ~ Petal.Width + Species, data) ) ``` ---
--- ```r make(plan) ## cache /home/muelleki/git/R/drake-pitch/.drake ## connect 4 imports: check_local_env, knit_print.data.frame, con... ## connect 4 targets: raw_data, data, hist, model ## check 10 items: 'raw-data.xlsx', aes, forcats::fct_inorder, ge... ## check 1 item: raw_data ## target raw_data ## check 1 item: data ## target data ## check 2 items: hist, model ## unload 1 item: raw_data ## target hist ## target model ``` --- ```r make(plan) ## cache /home/muelleki/git/R/drake-pitch/.drake ## Unloading targets from environment: ## hist ## data ## model ## connect 4 imports: check_local_env, knit_print.data.frame, con... ## connect 4 targets: raw_data, data, hist, model ## check 10 items: 'raw-data.xlsx', aes, forcats::fct_inorder, ge... ## check 1 item: raw_data ## check 1 item: data ## check 2 items: hist, model ## All targets are already up to date. ``` ---
--- ```r loadd(data, verbose = 0) data ## # A tibble: 150 x 6 ## X__1 Sepal.Length Sepal.Width Petal.Length Petal.Width ## <dbl> <dbl> <dbl> <dbl> <dbl> ## 1 1.00 5.10 3.50 1.40 0.200 ## 2 2.00 4.90 3.00 1.40 0.200 ## 3 3.00 4.70 3.20 1.30 0.200 ## 4 4.00 4.60 3.10 1.50 0.200 ## 5 5.00 5.00 3.60 1.40 0.200 ## 6 6.00 5.40 3.90 1.70 0.400 ## 7 7.00 4.60 3.40 1.40 0.300 ## 8 8.00 5.00 3.40 1.50 0.200 ## 9 9.00 4.40 2.90 1.40 0.200 ## 10 10.0 4.90 3.10 1.50 0.100 ## # ... with 140 more rows, and 1 more variable: Species <fct> ``` --- ```r loadd(hist, verbose = 0) hist ## `stat_bin()` using `bins = 30`. Pick better value with ## `binwidth`. ``` ![](index_files/figure-html/hist-1.png)<!-- --> --- ```r loadd(model, verbose = 0) model ## ## Call: ## lm(formula = Sepal.Width ~ Petal.Width + Species, data = data) ## ## Coefficients: ## (Intercept) Petal.Width Speciesversicolor ## 3.236 0.781 -1.501 ## Speciesvirginica ## -1.844 summary(model) ## ## Call: ## lm(formula = Sepal.Width ~ Petal.Width + Species, data = data) ## ## Residuals: ## Min 1Q Median 3Q Max ## -1.17017 -0.19105 0.00793 0.19173 0.85172 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 3.23587 0.05194 62.295 < 2e-16 *** ## Petal.Width 0.78102 0.12121 6.443 1.59e-09 *** ## Speciesversicolor -1.50150 0.14407 -10.422 < 2e-16 *** ## Speciesvirginica -1.84421 0.22399 -8.234 9.35e-14 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 0.3008 on 146 degrees of freedom ## Multiple R-squared: 0.5335, Adjusted R-squared: 0.5239 ## F-statistic: 55.65 on 3 and 146 DF, p-value: < 2.2e-16 ``` --- ```r plan <- drake_plan( raw_data = readxl::read_xlsx("raw-data.xlsx"), data = raw_data %>% mutate(Species = forcats::fct_inorder(Species)) %>% * select(-X__1), hist = ggplot(data, aes(x = Petal.Width, fill = Species)) + * geom_histogram(bins = 10), model = lm(Sepal.Width ~ Petal.Width + Species, data) ) ``` ---
--- ```r make(plan, verbose = 0) loadd(hist, verbose = 0) hist ``` ![](index_files/figure-html/make-fixed-1.png)<!-- -->