From f9cc53e25023a6033d72f10f205250470a444cc9 Mon Sep 17 00:00:00 2001 From: Anders Askeland Date: Wed, 7 Aug 2024 14:11:52 +0200 Subject: [PATCH] =?UTF-8?q?docs(sessions):=20=F0=9F=93=9D=20add=20learning?= =?UTF-8?q?=20objectives=20to=20function=20development=20(#25)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Luke W. Johnston Co-authored-by: Luke W. Johnston --- sessions/function-development.qmd | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/sessions/function-development.qmd b/sessions/function-development.qmd index c2ebb85..2ddd795 100644 --- a/sessions/function-development.qmd +++ b/sessions/function-development.qmd @@ -28,13 +28,24 @@ package, documenting them, and how to stop your functions with an error. - To use `@examples` to help with creating function? - Function documentation (with roxygen2), part 1? -**Session objectives**: +## Learning objectives -- Convert a chunk of R code into a function -- Include a function in an R package -- Provide basic function documentation using Roxygen -- Use functions from other packages in a function in your own package -- Return an error message from a function +The overall **learning outcome** for this session is: + +1. Review the core workflow in creating functions and describe + additional workflows and software development principles required to + formally (and effectively) develop functions within an R package. + +Specific **objectives** are: + +- Review and apply the workflow for converting code into a function. +- Identify approaches and "code patterns" for writing your functions + that ensure they are internally self-contained and reusable. +- Explain what package dependency means in the context of packages and + how you formally manage dependencies when writing functions as part + of a package. +- Use control flow processes like `if () {} else() {}` to modify what + a function does based on a condition. ## TODO: Section @@ -62,7 +73,7 @@ release_date_line <- str_subset(text, "Release Date: ") release_date <- str_remove(release_date_line, "Release Date: ") tibble( - author = author, + author = author, title = title, release_date = release_date ) @@ -222,7 +233,7 @@ book_meta(dracula) ```{r sol-extract-element-dep} # + change to DESCRIPTION -extract_element <- function(text, element){ +extract_element <- function(text, element) { line <- stringr::str_subset(text, element) value <- stringr::str_remove(line, element) value