Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make function hai_hyperbolic_augment() #70

Closed
spsanderson opened this issue Nov 4, 2021 · 0 comments
Closed

Make function hai_hyperbolic_augment() #70

spsanderson opened this issue Nov 4, 2021 · 0 comments
Assignees
Labels
function A new function
Projects

Comments

@spsanderson
Copy link
Owner

hai_hyperbolic_augment <- function(.data
                               , .value
                               , .names = "auto"
                               , .scale_type = c("sin","cos","tan","all")
                               ){
  
  column_expr <- rlang::enquo(.value)
  
  if(rlang::quo_is_missing(column_expr)) stop(call. = FALSE, "hyperbolic_augment(.value) is missing.")
  
  col_nms <- names(tidyselect::eval_select(rlang::enquo(.value), .data))
  
  make_call <- function(col, scale_type){
    rlang::call2(
      "hai_hyperbolic_vec",
      x             = rlang::sym(col)
      , .scale_type = scale_type
      #, .ns = "healthyR.ai"
    )
  }
  
  grid <- expand.grid(
    col                = col_nms
    , scale_type       = .scale_type
    , stringsAsFactors = FALSE
  )
  
  calls <- purrr::pmap(.l = list(grid$col, grid$scale_type), make_call)
  
  if(any(.names == "auto")) {
    newname <- paste0(grid$col, "_", grid$scale_type)
  } else {
    newname <- as.list(.names)
  }
  
  calls <- purrr::set_names(calls, newname)
  
  ret <- tibble::as_tibble(dplyr::mutate(.data, !!!calls))
  
  return(ret)
    
}
@spsanderson spsanderson added the function A new function label Nov 4, 2021
@spsanderson spsanderson added this to the healthyR.ai 0.0.3 milestone Nov 4, 2021
@spsanderson spsanderson self-assigned this Nov 4, 2021
@spsanderson spsanderson added this to To do in healthyR.ai via automation Nov 4, 2021
healthyR.ai automation moved this from To do to Done Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
function A new function
Projects
Development

No branches or pull requests

1 participant