Skip to content

Commit

Permalink
Merge pull request #1 from rserran/master
Browse files Browse the repository at this point in the history
Add Chapter 11 notes
  • Loading branch information
rserran authored Mar 19, 2024
2 parents 0b46a04 + 4f7f0a6 commit a7db5b1
Show file tree
Hide file tree
Showing 98 changed files with 18,541 additions and 0 deletions.
6,826 changes: 6,826 additions & 0 deletions Reproducible_pipelines_book_club/Meeting_06/bootstrap.css

Large diffs are not rendered by default.

133 changes: 133 additions & 0 deletions Reproducible_pipelines_book_club/Meeting_06/chapter_11.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
title: |
| Building reproducible analytical pipelines with R
| Chapter 11 - Packaging your code
author: "B. Rodrigues / Ricardo J. Serrano"
date: "3/21/2024"
output:
slidy_presentation:
css: bootstrap.css
highlight: tango
theme: cosmo
df_print: paged
editor_options:
chunk_output_type: console
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE,
eval = FALSE, fig.width = 10, fig.height = 10)
```

#

**About me**

- Industrial engineer/machinery and equipment appraiser
- Manufacturing (electronics/pharmaceuticals)
- 10 years - part-time faculty member in a local college
- Started a career change in 2019
- Co-organizer [Orlando Machine Learning and Data Science meetup](https://www.meetup.com/Orlando-MLDS/)
- [LinkedIn](https://www.linkedin.com/in/ricardojserrano/)

#

**Learning objectives:**

- How to convert the analysis that we have done so far into a **package**.
- List benefits of developing a package.
- Introduce `{fusen}` package to accelerate the process of building your package.
- How to turn .Rmd files, including datasets, into a package.
- Installing and sharing the package.
- Conclusions

#

- Have you created an R package?

#

- Have you created an R package?

- Which R package(s) do you use frequently?

# **What is a package in R?**

- In R, the fundamental unit of shareable code is the **package**.
![Source: https://pixabay.com/](img/package-img.webp){height=640px width=480px}

- In simple terms, a package bundles together:
* code
* data
* documentation
* tests

- Makes it easier to share with other users.

# **Benefits of developing an R package**

- Reproducibility

- Makes it easier to reuse across projects

- Facilitates collaboration

# Introduction to `{fusen}`

![Source: https://rawgit.com/rstudio/cheatsheets/main/package-development.pdf](img/10-createpackage-packagestructure.png)

#

![Source: https://thinkr-open.github.io/fusen/](img/fusen_inflate_functions.png)

# **`{fusen}` process steps**

```{r load-fusen-script}
if (!require("fusen")){
install.packages("fusen")
library(fusen)
}
```

Start an R session from your home (or Documents) directory and run the following:
```{r create-fusen}
fusen::create_fusen(path = "fusen.quickstart",
template = "minimal")
```

The `create_fusen` function creates:

- a directory called `fusen.quickstart` in your Home directory
- creates a `fusen.quickstart.Rproj` file
- creates subfolders 'dev/' and 'R/

![](img/create_fusen.png){height=800px width=1000px}

![](img/dev_folder.png){height=800px width=1000px}

#

![](img/flat_minimal_rmd.png){height=800px width=1000px}

#

![](img/0_dev_history_rmd.png){height=800px width=1000px}

#

Example of `DESCRIPTION` file

![](img/example_description_file.png){height=800px width=1000px}

#

Run code chunk named 'description' in an R console.

![](img/description_code_chunk_results.png){height=800px width=1000px}

#

Run 'development-inflate' code chunk.

![](img/development_inflate_results.png){height=800px width=1000px}

Loading

0 comments on commit a7db5b1

Please sign in to comment.