README.md

easyBakeOven

R Package that facilitates various aspects of R package authorship and deployment in tandem with the usethis, devtools, and sinew packages. Features include:

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("meerapatelmd/easyBakeOven")

Example

Printing arguments and their values in the R console

If you have the following functions:

love <- 
        function(thing_i_love) {

                sprintf("I love %s.", thing_i_love)

        }

like <- 
        function(thing_i_like) {

                sprintf("I like %s.", thing_i_like)

        }

You want to print what you love or what you like. For example, if you love apples:

love("apples")
#> [1] "I love apples."

If you like bananas:

like("bananas")
#> [1] "I like bananas."

What if I want to author a new function that prints both things I love and things I like in a single function call?

I can use easyBakeOven’s make_args functions to return arguments and their values for love() and like() to copy-and-paste into the new function.

library(easyBakeOven)
library(tidyverse)

The default and internal arguments from love() are:

make_args(love)
#> thing_i_love
#> 
#> thing_i_love = thing_i_love

The same for like() are:

make_args(like)
#> thing_i_like
#> 
#> thing_i_like = thing_i_like

I can then copy-and-paste the results from the above calls to make_args to author like_and_love(). Starting with the default values for the arguments for both functions, both of which are missing.

like_and_love <-
        # Added default arguments
        function(thing_i_love,
                 thing_i_like) {


        }

The internal arguments can then be copy-and-pasted.

like_and_love <-
        function(thing_i_love,
                 thing_i_like) {

                         sprintf("%s AND %s",
                                 # Added internal arguments
                                 love(thing_i_love = thing_i_love),
                                 like(thing_i_like = thing_i_like))

        }

The function is now authored and executable.

like_and_love(thing_i_love = "apples",
              thing_i_like = "bananas")
#> [1] "I love apples. AND I like bananas."

Code of Conduct

Please note that the suzyBakeOven project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.



meerapatelmd/suzyBakeOven documentation built on March 30, 2022, 1:44 p.m.