From a6cd927538fdd466fe4b0cb0dac57962ad06b483 Mon Sep 17 00:00:00 2001 From: Ryan DeStefano Date: Mon, 13 May 2024 10:41:00 -0700 Subject: [PATCH 1/5] Fixed give candygrams function --- R/give_candygrams.R | 2 +- README.md | 7 +++---- 2 files changed, 4 insertions(+), 5 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..f06cad8 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 @@ -92,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 @@ -100,10 +99,10 @@ behavior: ``` r give_candygrams("Glen Coco", 4) -#> Four for Glen Coco. +#> Four for Glen Coco. You go, Glen Coco! ``` ``` r give_candygrams("Gretchen Weiners", 4) -#> [1] "None for Grethen Weiners." +#> None for Gretchen Weiners. ``` From 75747e5720e2f43ae47ff828589c8e13565ab284 Mon Sep 17 00:00:00 2001 From: Ryan DeStefano Date: Mon, 13 May 2024 10:49:42 -0700 Subject: [PATCH 2/5] breh --- R/give_candygrams.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/give_candygrams.R b/R/give_candygrams.R index 67cadcb..4a983ec 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}. {extra_message}") + glue::glue("{number} for {person}.{extra_message}") From 0263f8604ad992556a158a07a6ef523824b9db92 Mon Sep 17 00:00:00 2001 From: Ryan DeStefano Date: Mon, 13 May 2024 10:54:52 -0700 Subject: [PATCH 3/5] Changed default arg to False for follow up measage --- R/compliments.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/compliments.R b/R/compliments.R index e0066f2..89b48be 100644 --- a/R/compliments.R +++ b/R/compliments.R @@ -7,7 +7,7 @@ #' @return A compliment string #' #' @export -really_pretty <- function(name, follow_up = TRUE) { +really_pretty <- function(name, follow_up = FALSE) { compliment <- glue::glue("You're, like, really pretty, {name}.") From 9517c770755c41264d8ac55cd9706c0a257e48eb Mon Sep 17 00:00:00 2001 From: Ryan DeStefano Date: Mon, 13 May 2024 10:56:03 -0700 Subject: [PATCH 4/5] Got rid of comma --- R/compliments.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/compliments.R b/R/compliments.R index 89b48be..bffdae0 100644 --- a/R/compliments.R +++ b/R/compliments.R @@ -9,7 +9,7 @@ #' @export really_pretty <- function(name, follow_up = FALSE) { - compliment <- glue::glue("You're, like, really pretty, {name}.") + compliment <- glue::glue("You're, like, really pretty {name}.") if (follow_up) { compliment <- paste(compliment, From 27c09a2218c05f4af399ee0828e85cf2480e8d8e Mon Sep 17 00:00:00 2001 From: Ryan DeStefano Date: Mon, 13 May 2024 11:24:00 -0700 Subject: [PATCH 5/5] Create give cnadgrams function --- R/give_candygrams.R | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/R/give_candygrams.R b/R/give_candygrams.R index 4a983ec..97f5873 100644 --- a/R/give_candygrams.R +++ b/R/give_candygrams.R @@ -36,6 +36,44 @@ give_candygrams <- function(person, number, } + +#' Announces the number of candygrams for 1 or more people. +#' +#' @param people The candygram recipients +#' @param numbers How many grams they got +#' @param extra_message A vector of possible extra commentary. +#' +#' @return A candy gram announcement +#' +#' @importFrom stringr str_detect str_to_title +#' @importFrom english as.english +#' +#' @export +give_many_candygrams <- function(people, numbers, + extra_messages = NULL) { + + for (i in 1:length(people)) { + + if(is.na(extra_messages[i])){ + + print(give_candygrams(people[i], numbers[i])) + + } + + else { + + print(give_candygrams(people[i], numbers[i], extra_messages[i])) + + } + + } + +} + +people <- c("Ryan", "Lukas", "Richard", "David") +numbers <- c(10, 10, 3, 20) +extra_messages <- c("Incredible", NULL, NULL, NULL) + #' Tacks commentary on to candygram announcement #' #' @param person The candygram recipient