forked from ThinkR-open/wedding
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
912 additions
and
442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ | |
^Meta$ | ||
^\.secrets$ | ||
^\.github$ | ||
^codecov\.yml$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#' Add information about guests in the database | ||
#' | ||
#' @param info_to_add Tibble. Information to be added. | ||
#' @param data_guests Tibble. Initial table. | ||
#' | ||
#' @importFrom dplyr distinct pull filter select left_join bind_rows arrange | ||
#' | ||
#' @return Tibble. | ||
#' @export | ||
#' | ||
#' @examples | ||
#' info_to_add_in_data_guests <- tibble::tibble( | ||
#' name = c("David", "Margot"), | ||
#' here_cocktail = rep("Yes", 2), | ||
#' here_diner = rep("Yes", 2), | ||
#' here_sunday = rep("Yes", 2), | ||
#' special_diet = c(NA_character_, "I am vegan"), | ||
#' menu_diner = rep("Adult", 2), | ||
#' time_confirmation = rep("2021-04-22 09:57:12 CEST", 2) | ||
#' ) | ||
#' | ||
#' data(data_guests_example) | ||
#' | ||
#' add_info_guests_in_database(info_to_add = info_to_add_in_data_guests, | ||
#' data_guests = data_guests_example) | ||
add_info_guests_in_database <- function(info_to_add, data_guests) { | ||
|
||
names_guests_to_add <- info_to_add %>% | ||
distinct(name) %>% | ||
pull(name) | ||
|
||
data_guests_to_add <- data_guests %>% | ||
filter(name %in% names_guests_to_add) %>% | ||
select(name, type, table, announcement) %>% | ||
left_join(info_to_add, | ||
by = "name") | ||
|
||
new_data_guests <- data_guests %>% | ||
filter(!(name %in% names_guests_to_add)) %>% | ||
bind_rows(data_guests_to_add) %>% | ||
arrange(table) | ||
|
||
return(new_data_guests) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#' Count confirmations or non-confirmations | ||
#' | ||
#' @param filter_confirmation Character vectors. Conditions to be combined with a & | ||
#' @param data_guests Tibble. | ||
#' | ||
#' @importFrom glue glue_collapse | ||
#' @importFrom dplyr filter count pull | ||
#' | ||
#' @return Character. | ||
#' @export | ||
#' | ||
#' @examples | ||
#' data(data_guests_example) | ||
#' count_confirmations(filter_confirmation = c("type == 'Teen'", | ||
#' "(here_cocktail == 'No' | | ||
#' here_diner == 'No' | | ||
#' here_sunday == 'No')"), | ||
#' data_guests = data_guests_example) | ||
count_confirmations <- function(filter_confirmation, data_guests) { | ||
|
||
conditions <- glue_collapse(filter_confirmation, sep = " & ") | ||
|
||
data_guests %>% | ||
filter(eval(parse(text = conditions))) %>% | ||
count() %>% | ||
pull() %>% | ||
as.character() | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.