#' @title Initiate the R file to be created.
#'
#' @description Initiate the R file to be created.
#'
#' @author Briac LE RAY (briac.leray@partnre.com)
#'
#' @return Does not return anything.
#' @param file_path The path to the file you want to write in. Type = character
#' @examples initiate_R_file(file_path = "/path/to/the/file/file_name.extension")
initiate_R_file <- function(file_path) {
initiation_text = paste("# This code was generated using the package StressTestOptimization.",
"# https://github.com/Tiipiac/StressTestOptimization",
sep = "\n",
collapse = )
imports = paste("library(dplyr)",
"library(stringr)",
"library(tidyr)",
sep = "\n",
collapse = )
functions = paste("CREATE_TABLE<-function(sql, nom_table){",
"user=paste0(Sys.info()[\"user\"])",
"create_table<-paste0(\"use sandbox_\",user,\";",
"DROP TABLE IF EXISTS \",nom_table,\";",
"CREATE TABLE \",nom_table,\" as \", sql,\";\", '\"')",
"create_table1<-paste0(\"hive -e \",\" \\\" \")",
"system(paste0(create_table1, create_table), intern = FALSE)",
"}",
sep = "\n",
collapse = )
add_to_file(text = initiation_text, file_path = file_path, append = FALSE)
add_to_file(text = imports, file_path = file_path, append = TRUE)
add_to_file(text = functions, file_path = file_path, append = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.