class: right middle hide-count background-color: white background-image: url(img/enso.jpg) background-position: left <link href="https://fonts.googleapis.com/css?family=Cedarville+Cursive|Karla|Montserrat|Open+Sans|Quattrocento|Raleway&display=swap" rel="stylesheet"> <style type="text/css"> a, a > code { color: #D55E00FF; text-decoration: none; } em { color: #D55E00FF; font-style: normal; } del { color: #E5E5E5; text-decoration: none; font-weight: normal; } .inverse del { color: #6C7B7F; } .bg-white-o90{ background-color: rgba(255, 255, 255, 0.9); } .large { font-size: 175% } .hide-count .remark-slide-number { display: none; } .text-poster { font-family: 'Cinzel', serif; } .inverse { color: #b9bfca; background-color: #282D35 } .inverse.remark-slide-number { color: #b9bfca; } .remark-code-line-highlighted { color: #D55E00FF; background-color: transparent; } .remark-inline-code { color: #b9bfca; } .h2 { font-family: 'Karla' } </style> .pull-right[ # Zen and the Art of R Package development ] Malcolm Barrett <svg style="height:0.8em;top:.04em;position:relative;fill:#282D35;" viewBox="0 0 512 512"><path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"/></svg> @malco_barrett Slides: [bit.ly/zenrpkgs](http://bit.ly/zenrpkgs) --- # rstudio::conf(2020L) --- # rstudio::conf(2020L) ## [My Organizaton's First R Package](https://my-org-first-pkg-2020.netlify.com/) --- # rstudio::conf(2020L) ## ~~My Organizaton's First R Package~~ ## [R Markdown Driven Development](https://resources.rstudio.com/rstudio-conf-2020/rmarkdown-driven-development-emily-riederer) --- class: center middle
.footnote.pull-right[— Sandokai] --- class: center middle
--- class: center, middle, hide-count background-image: url(img/oxherding_1.jpg) background-size: cover
You already<br>structure your project
--- class: inverse, large ``` ├── data/ ├── reports/ ├── scripts/ └── analysis.Rproj ``` --- class: inverse, large ``` ├── data/ ├── reports/ *├── R/ └── analysis.Rproj ``` --- class: inverse, large ``` *├── data/ ├── reports/ ├── R/ └── analysis.Rproj ``` --- class: inverse, large ``` ├── data/ *├── vignettes/ ├── R/ └── analysis.Rproj ``` --- class: inverse, large ``` ├── data/ ├── vignettes/ ├── R/ *├── man/ *├── tests/ *├── DESCRIPTION *├── NAMESPACE └── analysis.Rproj ``` --- class: middle, inverse ![](img/svg/create_package.svg)<!-- --> --- class: inverse, large ``` ├── data/ ├── vignettes/ ├── R/ ├── man/ ├── tests/ *├── DESCRIPTION ├── NAMESPACE └── analysis.Rproj ``` --- class: inverse, large ``` Package: zenartofrpkgs Title: What the Package Does (One Line, Title Case) Version: 0.0.0.9000 Authors@R: person(given = "Malcolm", family = "Barrett", role = c("aut", "cre"), email = "malcolmbarrett@gmail.com", comment = c(ORCID = "0000-0003-0299-5825")) Description: What the package does (one paragraph). License: MIT + file LICENSE Encoding: UTF-8 LazyData: true ``` --- class: middle, inverse ![](img/svg/create_project.svg)<!-- --> --- class: center, middle, hide-count background-image: url(img/oxherding_2.jpg) background-size: cover
You already<br>write R code
--- class: middle, inverse ![](img/svg/write_code.svg)<!-- --> --- class: middle, inverse ![](img/svg/use_r.svg)<!-- --> --- class: middle, inverse ![](img/svg/write_functions.svg)<!-- --> --- class: middle, inverse ![](img/svg/load_all.svg)<!-- --> --- class: center, middle, hide-count background-image: url(img/oxherding_3.jpg) background-size: cover
You already<br>declare your dependencies
--- class: middle, inverse ![](img/svg/write_library.svg)<!-- --> --- class: middle, inverse ![](img/svg/use_package.svg)<!-- --> --- class: middle, inverse ![](img/svg/use_package_code.svg)<!-- --> --- class: inverse, large ``` Package: zenartofrpkgs Title: What the Package Does (One Line, Title Case) Version: 0.0.0.9000 Authors@R: person(given = "Malcolm", family = "Barrett", role = c("aut", "cre"), email = "malcolmbarrett@gmail.com", comment = c(ORCID = "0000-0003-0299-5825")) Description: What the package does (one paragraph). License: MIT + file LICENSE Encoding: UTF-8 LazyData: true ``` --- class: inverse, large ``` Package: zenartofrpkgs Title: What the Package Does (One Line, Title Case) Version: 0.0.0.9000 Authors@R: person(given = "Malcolm", family = "Barrett", role = c("aut", "cre"), email = "malcolmbarrett@gmail.com", comment = c(ORCID = "0000-0003-0299-5825")) Description: What the package does (one paragraph). License: MIT + file LICENSE Encoding: UTF-8 LazyData: true *Imports: * ggplot2 * dplyr ``` --- class: middle, inverse ![](img/svg/use_package_install.svg)<!-- --> --- class: center, middle, hide-count background-image: url(img/oxherding_4.jpg) background-size: cover
You already<br>test your code
--- class: middle, inverse ![](img/svg/fiddle.svg)<!-- --> --- class: middle, inverse ![](img/svg/use_test.svg)<!-- --> --- class: inverse, center, middle, hide-count # let's take a breath --- class: inverse # *Use a description file* --- class: inverse # ~~Use a description file~~ # *Write code as functions* --- class: inverse # ~~Use a description file~~ # ~~Write code as functions~~ # *Write down your tests; automate them* --- class: center middle
.footnote.pull-right[— Shunryu Suzuki Roshi] --- class: center middle
.footnote.pull-right[— Hadley Wickham] --- class: center, middle, hide-count background-image: url(img/oxherding_5.jpg) background-size: cover
You already<br>document your code
--- class: middle, inverse ![](img/svg/comment.svg)<!-- --> --- class: middle, inverse ![](img/svg/use_roxygen_rmd.svg)<!-- --> --- class: middle, inverse ``` #' Plot mean sepal length by species #' #' @param size the size of the points #' #' @return a ggplot #' @export #' #' @examples #' #' plot_iris() #' plot_iris <- function(size = 2) { iris %>% dplyr::group_by(Species) %>% dplyr::summarize(mean_sepal_length = mean(Sepal.Length)) %>% ggplot2::ggplot(ggplot2::aes(mean_sepal_length, Species)) + ggplot2::geom_point(size = 2) } ``` --- class: middle, inverse ![](img/svg/document.svg)<!-- --> --- class: center, middle, hide-count background-image: url(img/oxherding_6.jpg) background-size: cover
You already<br>clean your data
--- class: middle, inverse ![](img/svg/use_data_raw.svg)<!-- --> --- class: middle, inverse ![](img/svg/use_data.svg)<!-- --> --- class: center, middle, hide-count background-image: url(img/oxherding_7.png) background-size: cover
You already<br>write reports
--- class: middle, inverse ![](img/svg/use_vignette.svg)<!-- --> --- class: middle, inverse ![](img/svg/use_inst.svg)<!-- --> --- class: middle, inverse ![](img/svg/use_toplevel.svg)<!-- --> --- class: center, middle, hide-count background-image: url(img/oxherding_8.png) background-size: cover
You already<br>share your code
--- class: middle, inverse ![](img/svg/install.svg)<!-- --> --- class: center, middle, hide-count background-image: url(img/oxherding_9.jpg) background-size: cover
Coming home<br>to R packages
--- class: inverse, center, middle # [R Markdown Driven Development](https://emilyriederer.netlify.com/post/rmarkdown-driven-development/) --- class: inverse, center, middle # [rrtools](https://github.com/benmarwick/rrtools) --- class: inverse, center, middle # [golem](https://thinkr-open.github.io/golem/) --- class: inverse, center, middle # [drake](https://books.ropensci.org/drake/projects.html#workflows-as-r-packages) --- class: inverse, center, middle # an invitation -- ## *create a package: a personal R package, something for your work, or turn a project into a package* --- class: center middle
.footnote.pull-right[— Chögyam Trungpa Rinpoche] --- class: center, middle, hide-count background-image: url(img/oxherding_10.jpg) background-size: cover
What<br>next?
--- class: inverse, center, middle # [R Packages, 2nd Edition: Whole Game](https://r-pkgs.org/whole-game.html) --- class: middle, inverse ![](img/svg/goodbye.svg)<!-- -->