handling of no-op verbs
This commit is contained in:
Родитель
34aa070f59
Коммит
b2d57a5908
|
@ -38,6 +38,8 @@ datamation_sanddance <- function(pipeline, envir = rlang::global_env(), pretty =
|
|||
# Specify which functions are supported, for parsing functions out and for erroring if any are not in this list
|
||||
supported_tidy_functions <- c("group_by", "summarize", "filter", "count", "tally", "mutate")
|
||||
|
||||
discarded_noop_functions <- c("arrange", "select")
|
||||
|
||||
# Convert pipeline into list
|
||||
full_fittings <- pipeline %>%
|
||||
parse_pipeline(supported_tidy_functions)
|
||||
|
@ -78,8 +80,11 @@ datamation_sanddance <- function(pipeline, envir = rlang::global_env(), pretty =
|
|||
# Check that all functions are supported
|
||||
purrr::map(
|
||||
tidy_functions_list[-1], # Since the first one is data
|
||||
~ if (!(.x %in% supported_tidy_functions)) {
|
||||
~ if (!(.x %in% c(supported_tidy_functions, discarded_noop_functions))) {
|
||||
stop(paste(.x, "is not supported by `datamation_sanddance`"), call. = FALSE)
|
||||
} else if (.x %in% discarded_noop_functions) {
|
||||
tidy_functions_list <- setdiff(tidy_functions_list, discarded_noop_functions)
|
||||
warning(glue::glue('Pipeline step for {.x} discarded as a non-visualized function.'))
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -152,6 +157,8 @@ datamation_sanddance <- function(pipeline, envir = rlang::global_env(), pretty =
|
|||
verb <- tidy_function_args[[i]][[1]]
|
||||
}
|
||||
|
||||
if(verb %in% discarded_noop_functions) next
|
||||
|
||||
# Define which function to call for that step in the pipeline
|
||||
call_verb <- switch(verb,
|
||||
data = prep_specs_data,
|
||||
|
@ -163,6 +170,7 @@ datamation_sanddance <- function(pipeline, envir = rlang::global_env(), pretty =
|
|||
mutate = prep_specs_mutate
|
||||
)
|
||||
|
||||
|
||||
# Checks if the group_by occurs before this fitting
|
||||
if (!length(which(stringr::str_detect(names(tidy_function_args), "group_by")))==0 &&
|
||||
which(stringr::str_detect(names(tidy_function_args), "group_by")) < i) {
|
||||
|
@ -280,7 +288,7 @@ datamationSandDance_html <- function(...) {
|
|||
class = "button-wrapper",
|
||||
shiny::tags$button(
|
||||
class = "replay-btn",
|
||||
onclick = htmlwidgets::JS(paste0("window.", app_name, ".play('')")),
|
||||
onclick = htmlwidgets::JS(paste0("window.", app_name, ".play('')")),
|
||||
"Replay"
|
||||
)
|
||||
),
|
||||
|
@ -292,7 +300,7 @@ datamationSandDance_html <- function(...) {
|
|||
class = "button-wrapper",
|
||||
shiny::tags$button(
|
||||
class = "export-btn",
|
||||
onclick = htmlwidgets::JS(paste0("window.", app_name, ".exportGif('1')")),
|
||||
onclick = htmlwidgets::JS(paste0("window.", app_name, ".exportGif('1')")),
|
||||
shiny::icon("download")
|
||||
)
|
||||
),
|
||||
|
|
Загрузка…
Ссылка в новой задаче