library(readr)
dir <- normalizePath(tempdir(),winslash = "/")
file.copy(from = system.file("extdata/default", package = "lazytrade"),
to = dir, recursive = TRUE)
files_chr <- list.files(path = file.path(dir, "default"), all.files = TRUE,
pattern = ".chr", full.names = TRUE)
code_to_find <- 9142301
# find the path to the file with numeric code
file_i_need <- util_find_file_with_code(files = files_chr,
code_to_find = 9142301)
# find the path to the file with a character code
file_i_need <- util_find_file_with_code(files = files_chr,
code_to_find = 'BITCOIN')
# find the path to the file with a character code that is not exists in those files
file_i_need <- util_find_file_with_code(files = files_chr,
code_to_find = 'Banana')
# define a vector with settings to search
v_par <- c("StartHour")
v_val <- c(15)
# Replace integer values
file_i_need <- util_find_file_with_code(files = files_chr,
code_to_find = 9142301,
option_replace = TRUE,
v_settings = v_par,
v_values = v_val)
# define a vector with settings to search
v_par <- "UseMAFilter"
v_val <- FALSE
# Replace boolean values
file_i_need <- util_find_file_with_code(files = files_chr,
code_to_find = 9142301,
option_replace = TRUE,
v_settings = v_par,
v_values = v_val)
# Replace boolean values in specified file
file.copy(from = system.file("extdata/Falcon_D.set", package = "lazytrade"),
to = dir, recursive = TRUE)
file_i_need <- util_find_file_with_code(files = file.path(dir, "Falcon_D.set"),
code_to_find = 9142301,
option_replace = TRUE,
v_settings = v_par,
v_values = v_val)
Run the code above in your browser using DataLab