R/transform_by_x_y.R

Defines functions transform_by_x_y

Documented in transform_by_x_y

#' @title Transform by format
#' 
#' @description Converts the input by from the Confluence table into adequate format.
#' 
#' @author Briac LE RAY (briac.leray@partnre.com)
#' 
#' @return Returns a string matching the "by" format used in the merge function.
#' @param by_x_y The string to be transformed. Type = character
#' @examples transform_by_x_y(by_x_y = "attribute_1, attribute_2") 
#' returns : "c("attribute_1", "attribute_2")"

transform_by_x_y <- function(by_x_y) {
  by_x_y <- unlist(strsplit(x = by_x_y, split = ","))
  by_x_y <- str_replace_all(string = by_x_y, pattern = " ", replacement = "")
  by_x_y <- paste(by_x_y, collapse = "\", \"")
  by_x_y <- paste("c(\"", by_x_y, "\")", sep = "")
  return(by_x_y)
}
Tiipiac/StressTestOptimization documentation built on Dec. 18, 2021, 5:08 p.m.