The goal of cookie is to give a live demonstration for Matt Dray's talk about building a package: https://twitter.com/mattdray/status/1190683525005107200
You can install {cookie} from github with:
remotes::install_github("zkamvar/cookie")
This is a basic example which shows you how to solve a common problem:
library(cookie)
give_cookie("Zhian")
#> Zhian gets: a cookie!
#> [1] "a cookie"
give_cookie("Rob")
#> Rob gets: a cookie!
#> [1] "a cookie"
Here's how we went through to create this:
We set up the project with two commands:
# This will open a new RStudio session
usethis::create_package("~/Desktop/cookie")
# This creates the file called R/give_cookie.R and opens it
usethis::use_r("give_cookie.R")
After that, we wrote the give_cookie() function and added
documentation using the {roxygen2} package.
The man/
folder was created with:
devtools::document()
We then used the glue package and included it with:
usethis::use_package("glue")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.