Building reproducible analytical pipelines with R
Chapter 11 - Packaging your code
2024-03-21
{fusen} package to accelerate the process of building your package.Have you created an R package?
Which R package(s) do you use frequently?
In R, the fundamental unit of shareable code is the package. 
In simple terms, a package bundles together:
Makes it easier to share with other users.
Reproducibility
Makes it easier to reuse across projects
Facilitates collaboration
{fusen}Source: https://rawgit.com/rstudio/cheatsheets/main/package-development.pdf
Source: https://thinkr-open.github.io/fusen/
{fusen} process stepsStart an R session from your home (or Documents) directory and run the following:
The create_fusen function creates:
fusen.quickstart in your Home directoryfusen.quickstart.Rproj file

flat_minimal_package.Rmd file
0-dev_history.Rmd file
DESCRIPTION file

flat_minimal_package.Rmd file.
pkgdown documentation website
.Rmd files: save_data.Rmd and analyse_data.Rmd.Rmd fileanalyse_data.Rmd to save_data.Rmdrmd branch (git checkout rmd) and create a branch called fusen (git checkout -b fusen){fusen} flat template in a dev/ folderStart a fresh R session inside the housing/ folder, and run this code:

Move save_data.Rmd to dev/ folder

save_data.RmdFile should like this
Run description named chunk from the 0-dev-history.Rmd
Document save-data.Rmd using {roxygen2} -type comments (see example to document function-get_raw_data)
After the documentation changes, save_data.Rmd should look like this
Now, run the fusen::inflate()
0-dev_history.Rmd and look for the header “Including datasets”localdev/ and inflate itremotes::install_local(){fusen}.