Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ Imports:
glue,
stringr,
english
RoxygenNote: 7.1.2
RoxygenNote: 7.3.1
Suggests:
testthat (>= 2.1.0)
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
export(boo)
export(fetch)
export(give_candygrams)
export(give_many_candygrams)
export(nice_style)
export(really_pretty)
importFrom(english,as.english)
importFrom(purrr,pmap)
importFrom(stringr,str_detect)
importFrom(stringr,str_to_title)
4 changes: 2 additions & 2 deletions R/compliments.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#' @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}.")
compliment <- glue::glue("You're, like, really pretty {name}.")

if (follow_up) {
compliment <- paste(compliment,
Expand Down
3 changes: 2 additions & 1 deletion R/give_candygrams.R
Original file line number Diff line number Diff line change
Expand Up @@ -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}")



Expand Down Expand Up @@ -61,3 +61,4 @@ add_commentary <- function(person, number) {
return("")

}

34 changes: 34 additions & 0 deletions R/give_many_candygrams.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#' Gives Multiple Candygrams
#'
#' @param students The a vector of student names
#' @param number The number of candygrams each student received
#' @param extra_messages Extra commentary for each candygram
#'
#' @return A vector of candygram announcements
#'
#' @importFrom purrr pmap
#'
#' @export

give_many_candygrams <- function(students, counts,
extra_messages = NULL){
# Checks:
# Length above 1
# Equal lengths
if(length(students) <= 1) {
print(length(students))
stop("Must input more than 1 candygram.")
}
if(length(students) != length(counts) |
(!is.null(extra_messages) & length(students) != length(extra_messages))){
stop("Vector lengths do not match.")
}

# If given extra_messages, use them
if(!is.null(extra_messages)){
purrr::pmap_chr(.l = list(students, counts, extra_messages),
.f = give_candygrams)
}
purrr::pmap_chr(.l = list(students, counts),
.f = give_candygrams)
}
3 changes: 3 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,7 @@ give_candygrams("Glen Coco", 4)
give_candygrams("Gretchen Weiners", 4)
```

```{r}
give_many_candygrams(c("Bob", "Joe"), c(1,2))
```

21 changes: 21 additions & 0 deletions man/give_many_candygrams.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/really_pretty.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.