Skip to content

Commit

Permalink
update code: updated code attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Apr 18, 2024
1 parent 77f1634 commit 8661838
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions R/update-variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,21 @@ update_variables_server <- function(id, data, height = NULL) {

return(reactive({
data <- updated_data$x
code <- list()
if (!is.null(data) && isTruthy(updated_data$list_mutate) && length(updated_data$list_mutate) > 0) {
attr(data, "code_01_mutate") <- call2("mutate", !!!updated_data$list_mutate)
code <- c(code, list(call2("mutate", !!!updated_data$list_mutate)))
}
if (!is.null(data) && isTruthy(updated_data$list_rename) && length(updated_data$list_rename) > 0) {
attr(data, "code_02_rename") <- call2("rename", !!!updated_data$list_rename)
code <- c(code, list(call2("rename", !!!updated_data$list_rename)))
}
if (!is.null(data) && isTruthy(updated_data$list_select) && length(updated_data$list_select) > 0) {
attr(data, "code_03_select") <- expr(select(-any_of(c(!!!updated_data$list_select))))
code <- c(code, list(expr(select(-any_of(c(!!!updated_data$list_select))))))
}
if (length(code) > 0) {
attr(data, "code") <- Reduce(
f = function(x, y) expr(!!x %>% !!y),
x = code
)
}
return(data)
}))
Expand Down

0 comments on commit 8661838

Please sign in to comment.