From 157c7e73d086141b2a4573a56187a17f1f1847bb Mon Sep 17 00:00:00 2001 From: yjunechoe Date: Sun, 4 Aug 2024 13:44:10 +0900 Subject: [PATCH 1/2] escape single quote --- R/steps_and_briefs.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/steps_and_briefs.R b/R/steps_and_briefs.R index 63f92f96d..ccb2a63c1 100644 --- a/R/steps_and_briefs.R +++ b/R/steps_and_briefs.R @@ -187,9 +187,10 @@ apply_segments_to_tbl <- function(agent, idx, tbl) { } # Generate a second set of 'preconditions' to filter the table + seg_val <- gsub("'", "\\\\'", seg_val) preconditions <- stats::as.formula( - glue::glue("~ . %>% dplyr::filter({seg_col} == '{seg_val}')") + glue::glue("~ . %>% dplyr::filter(`{seg_col}` == '{seg_val}')") ) tbl <- apply_preconditions(tbl = tbl, preconditions = preconditions) From 2dee3fb86c6a50cb68f49eca4f1c1b40e4735a40 Mon Sep 17 00:00:00 2001 From: yjunechoe Date: Sun, 4 Aug 2024 13:44:36 +0900 Subject: [PATCH 2/2] wrap glued column names in backticks --- R/info_add.R | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/R/info_add.R b/R/info_add.R index 44739cdb3..b11a9ab1b 100644 --- a/R/info_add.R +++ b/R/info_add.R @@ -1365,9 +1365,9 @@ snip_list <- function( stats::as.formula( as.character( glue::glue( - "~ . %>% dplyr::select(<>) %>%", + "~ . %>% dplyr::select(`<>`) %>%", "dplyr::distinct() %>%", - "dplyr::pull(<>) %>%", + "dplyr::pull(`<>`) %>%", ifelse(reverse, "rev() %>%", ""), "pb_str_catalog( limit = <>, @@ -1389,16 +1389,16 @@ snip_list <- function( stats::as.formula( as.character( glue::glue( - "~ . %>% dplyr::select(<>) %>%", - "dplyr::group_by(<>) %>%", + "~ . %>% dplyr::select(`<>`) %>%", + "dplyr::group_by(`<>`) %>%", "dplyr::summarize(`_count_` = dplyr::n(), .groups = 'keep') %>%", ifelse( reverse, "dplyr::arrange(`_count_`) %>%", "dplyr::arrange(dplyr::desc(`_count_`)) %>%" ), - "dplyr::select(<>) %>%", - "dplyr::pull(<>) %>%", + "dplyr::select(`<>`) %>%", + "dplyr::pull(`<>`) %>%", "pb_str_catalog( limit = <>, sep = <>, @@ -1420,9 +1420,9 @@ snip_list <- function( stats::as.formula( as.character( glue::glue( - "~ . %>% dplyr::select(<>) %>%", + "~ . %>% dplyr::select(`<>`) %>%", "dplyr::distinct() %>%", - "dplyr::pull(<>) %>%", + "dplyr::pull(`<>`) %>%", ifelse( reverse, "sort(decreasing = TRUE) %>%", @@ -1533,7 +1533,7 @@ snip_stats <- function( as.character( glue::glue( "~ . %>% - dplyr::select(<>) %>% + dplyr::select(`<>`) %>% pb_str_summary(type = '<>')", .open = "<<", .close = ">>" ) @@ -1607,8 +1607,8 @@ snip_lowest <- function(column) { as.character( glue::glue( "~ . %>% - dplyr::select(<>) %>% dplyr::distinct() %>% - dplyr::summarize(`pb_summary` = min(<>, na.rm = TRUE)) %>% + dplyr::select(`<>`) %>% dplyr::distinct() %>% + dplyr::summarize(`pb_summary` = min(`<>`, na.rm = TRUE)) %>% dplyr::pull(`pb_summary`) %>% as.character()", .open = "<<", .close = ">>" ) @@ -1681,8 +1681,8 @@ snip_highest <- function(column) { as.character( glue::glue( "~ . %>% - dplyr::select(<>) %>% dplyr::distinct() %>% - dplyr::summarize(`pb_summary` = max(<>, na.rm = TRUE)) %>% + dplyr::select(`<>`) %>% dplyr::distinct() %>% + dplyr::summarize(`pb_summary` = max(`<>`, na.rm = TRUE)) %>% dplyr::pull(`pb_summary`) %>% as.character()", .open = "<<", .close = ">>" )