From 85c910f6c345aece18c033c02a05c8c2aa65a78c Mon Sep 17 00:00:00 2001 From: Katherine Chan Date: Mon, 13 May 2024 10:46:52 -0700 Subject: [PATCH 1/3] Change give_candygrams() to print extra message --- R/give_candygrams.R | 2 +- README.md | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/R/give_candygrams.R b/R/give_candygrams.R index 8d71397..67cadcb 100644 --- a/R/give_candygrams.R +++ b/R/give_candygrams.R @@ -30,7 +30,7 @@ give_candygrams <- function(person, number, number <- str_to_title(as.english(number)) - glue::glue("{number} for {person}.") + glue::glue("{number} for {person}. {extra_message}") diff --git a/README.md b/README.md index 876c029..513570c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ # meangirls - The goal of meangirls is to create quotes in the style of the 2004 @@ -105,5 +104,5 @@ give_candygrams("Glen Coco", 4) ``` r give_candygrams("Gretchen Weiners", 4) -#> [1] "None for Grethen Weiners." +#> None for Gretchen Weiners. ``` From a743ac0bfb7532cd84fe5ad56302f1010398112f Mon Sep 17 00:00:00 2001 From: Katherine Chan Date: Mon, 13 May 2024 10:48:16 -0700 Subject: [PATCH 2/3] Update knitted readme file --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 513570c..f06cad8 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ You can also give extra commentary to your announcement: ``` r give_candygrams("Taylor Zimmerman", 2, extra_message = "Merry Christmas!") -#> Two for Taylor Zimmerman. +#> Two for Taylor Zimmerman. Merry Christmas! ``` Some special cases trigger automatic extra commentary or special @@ -99,7 +99,7 @@ behavior: ``` r give_candygrams("Glen Coco", 4) -#> Four for Glen Coco. +#> Four for Glen Coco. You go, Glen Coco! ``` ``` r From fb1c570b06ef920ffea5fe37ad88e77fcc492064 Mon Sep 17 00:00:00 2001 From: Katherine Chan Date: Mon, 13 May 2024 23:06:41 -0700 Subject: [PATCH 3/3] Fix give_candygrams to show extra messages (without whitespace) --- R/give_candygrams.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/give_candygrams.R b/R/give_candygrams.R index 67cadcb..21dc3cd 100644 --- a/R/give_candygrams.R +++ b/R/give_candygrams.R @@ -6,7 +6,7 @@ #' #' @return A candy gram announcement #' -#' @importFrom stringr str_detect str_to_title +#' @importFrom stringr str_detect str_to_title str_trim #' @importFrom english as.english #' #' @export @@ -17,7 +17,7 @@ give_candygrams <- function(person, number, if (str_detect(person, "Gretchen")) { - return(cat("None for Gretchen Weiners.")) + return("None for Gretchen Weiners.") } @@ -30,7 +30,7 @@ give_candygrams <- function(person, number, number <- str_to_title(as.english(number)) - glue::glue("{number} for {person}. {extra_message}") + str_trim(glue::glue("{number} for {person}. {extra_message}"))