From f978f5361cac9c98bd218c34950d43088f340bd9 Mon Sep 17 00:00:00 2001 From: serkor1 <77464572+serkor1@users.noreply.github.com> Date: Sat, 9 Dec 2023 09:34:23 +0100 Subject: [PATCH] Cleaned up codes Removed unnecessary codes in helpers and utils --- R/helper.R | 138 ----------------------------------------------------- R/utils.R | 19 ++++++++ 2 files changed, 19 insertions(+), 138 deletions(-) diff --git a/R/helper.R b/R/helper.R index 38252674..eaf26a81 100644 --- a/R/helper.R +++ b/R/helper.R @@ -5,81 +5,6 @@ # function # script start; - - -constructInterval <- function(source, futures, interval) { - - # 1) construct the interval - interval <- get( - paste0(source, 'Intervals') - )( - futures = futures, - interval = interval - ) - - # 2) return the interval - return( - interval - ) - -} - - - -# check_interval <- function( -# interval -# ) { -# -# indicator <- grepl( -# pattern = paste0( -# collapse = '|', -# available_intervals() -# ), -# x = interval -# ) -# -# if (!indicator) { -# -# rlang::abort( -# message = paste0('Chosen interval: "', interval, '" is not available.'), -# body = 'Use availableIntervals()-function to see a full list.', -# call = NULL -# ) -# -# } -# -# -# } - - - - -convert_date <- function( - input - ) { - - # Was: - # format( - # as.numeric( - # as.POSIXct(to,tz = 'UTC' - # ) - # ) * 1e3, - # cientific = FALSE - # ) - - as.POSIXct( - as.numeric(input)/1e3, - origin = '1970-01-01' - ) - - - -} - - - - - # generate data; # this data is for the purpose of presenting # and error-testing @@ -184,69 +109,6 @@ generate_data <- function( } - - - - -convertIndicator <- function(indicator) { - - # 1) convert indicator - # list.wise - indicator <- as.list( - indicator - ) - - # 2) extract names - # from the list - indicator_names <- names( - indicator - ) - - # 3) convert the - # list to a long - # data.frame - indicator <- do.call( - rbind, - lapply( - X = seq_along(indicator_names), - FUN = function(i) { - - # 1) store the values - # in a variable - x <- indicator[[i]] - - # 2) set column name - # to value - colnames(x) <- 'value' - - # 3) convert to - # data.frame - x <- toDF( - x - ) - - # 4) add label - # to the data - x$label <- indicator_names[i] - - return( - x - ) - - } - - ) - ) - - - - return( - indicator - ) - -} - - toDF <- function(quote) { diff --git a/R/utils.R b/R/utils.R index aa92496d..1a7e8614 100644 --- a/R/utils.R +++ b/R/utils.R @@ -7,6 +7,25 @@ +constructInterval <- function(source, futures, interval) { + + # 1) construct the interval + interval <- get( + paste0(source, 'Intervals') + )( + futures = futures, + interval = interval + ) + + # 2) return the interval + return( + interval + ) + +} + + + # base-url; baseUrl <- function( source = 'binance',