diff --git a/.Rbuildignore b/.Rbuildignore index 247572e..49617da 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -14,3 +14,7 @@ ^docs$ ^pkgdown$ ^revdep$ +^Dockerfile$ +^Main\.R +^docker-compose\.yaml +^UnnamedFileRapi\.xlsx$ diff --git a/.github/workflows/rhub.yaml b/.github/workflows/rhub.yaml new file mode 100644 index 0000000..74ec7b0 --- /dev/null +++ b/.github/workflows/rhub.yaml @@ -0,0 +1,95 @@ +# R-hub's generic GitHub Actions workflow file. It's canonical location is at +# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml +# You can update this file to a newer version using the rhub2 package: +# +# rhub::rhub_setup() +# +# It is unlikely that you need to modify this file manually. + +name: R-hub +run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}" + +on: + workflow_dispatch: + inputs: + config: + description: 'A comma separated list of R-hub platforms to use.' + type: string + default: 'linux,windows,macos' + name: + description: 'Run name. You can leave this empty now.' + type: string + id: + description: 'Unique ID. You can leave this empty now.' + type: string + +jobs: + + setup: + runs-on: ubuntu-latest + outputs: + containers: ${{ steps.rhub-setup.outputs.containers }} + platforms: ${{ steps.rhub-setup.outputs.platforms }} + + steps: + # NO NEED TO CHECKOUT HERE + - uses: r-hub/actions/setup@v1 + with: + config: ${{ github.event.inputs.config }} + id: rhub-setup + + linux-containers: + needs: setup + if: ${{ needs.setup.outputs.containers != '[]' }} + runs-on: ubuntu-latest + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.containers) }} + container: + image: ${{ matrix.config.container }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/run-check@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + + other-platforms: + needs: setup + if: ${{ needs.setup.outputs.platforms != '[]' }} + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.platforms) }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/setup-r@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/run-check@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} diff --git a/DESCRIPTION b/DESCRIPTION index 0ad7cb7..8d8a1c9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: Rapi Type: Package -Title: Interface for Multiple Data Providers 'EDDS' and 'FRED' -Version: 1.0.5 -Date: 2024-04-06 +Title: Interface for Multiple Data Providers `EDDS` and `FRED` +Version: 1.0.6 +Date: 2025-01-13 Authors@R: c( person("Sermet", "Pekin", , "sermet.pekin@gmail.com", role = c("aut", "cre" , "cph")) ) @@ -10,9 +10,9 @@ Maintainer: Sermet Pekin URL: https://github.com/DataRapi/Rapi, https://DataRapi.github.io/Rapi/ BugReports: https://github.com/DataRapi/Rapi/issues Description: Interface for multiple data sources, such as the - 'EDDS' API of the + `EDDS` API of the Central Bank of the Republic of Türkiye and the - 'FRED' API of the Federal Reserve Bank. + `FRED` API of the Federal Reserve Bank. Both data providers require API keys for access, which users can easily obtain by creating accounts on their respective websites. The package provides caching ability with the selection of periods to increase the @@ -26,26 +26,12 @@ LinkingTo: Rcpp Depends: R (>= 3.4.3), Rcpp -Imports: - crayon, - digest, - dplyr, - httr, - httr2, - glue, - jsonlite, - lubridate, - magrittr, - purrr, - rlang, - rlist, - stringr, - tibble -Suggests: - writexl , - devtools, - testthat +Imports: crayon, digest, dplyr, + httr, httr2, glue, jsonlite, + lubridate, magrittr, purrr, rlang, + rlist, stringr, tibble, writexl +Suggests: devtools, testthat Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Encoding: UTF-8 Config/testthat/edition: 3 diff --git a/NEWS.md b/NEWS.md index 25adb34..40e6b2f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # Rapi (development version) +# Rapi 1.0.6 +* Better `set_api_key` function was implemented. +* moved `writexl` package from suggested to required. + # Rapi 1.0.5 * Moved key parameter to the header for the source `EVDS`. @@ -8,4 +12,4 @@ # Rapi 1.0.3 -* Initial CRAN submission. (previously named vyos) +* Initial CRAN submission. (previously named `vyos`) diff --git a/R/api_keys.R b/R/api_keys.R index b0d6148..19a7509 100644 --- a/R/api_keys.R +++ b/R/api_keys.R @@ -142,14 +142,14 @@ show_usage <- function(func_name = "set_api_key", #' set_api_key #' -#' @param key api key of the source -#' @param source_name evds or fred -#' @param option choice of later usage. env or file should be given to -#' save api key for later use. Default is env which -#' saves api key as environment variable. -#' if `env` default value is selected it will save api key +#' @param key API key of the source +#' @param source_name `evds` or `fred` +#' @param option choice of later usage. `env` or file should be given to +#' save API key for later use. Default is env which +#' saves API key as environment variable. +#' if `env` default value is selected it will save API key #' as an environment variable -#' if `file` was selected it will save api key to current folder. +#' if `file` was selected it will save API key to current folder. #' @param ... for future versions #' @return #' The function has no return value. diff --git a/R/excel.R b/R/excel.R index 0d4a83f..75e7ca8 100644 --- a/R/excel.R +++ b/R/excel.R @@ -2,14 +2,14 @@ #' Rapi_GETPREP object. #' @description #' The excel() function creates an excel file according to the object given. -#' data.frame or List of data frame or Rapi_GETPREP object can be passed.. +#' `data.frame` or List of data frame or `Rapi_GETPREP` object can be passed.. #' @param dfs object or list of data frame to write #' @param file_name file name to save #' @param folder folder to save file #' @param .debug for internal use #' @param env environment #' @param ... for future versions -#' @return it returns object or list of data frame back +#' @return it returns object or list of `dataframe` back #' @export #' @examples #' \dontrun{ diff --git a/R/get_series_export.R b/R/get_series_export.R index b4584c1..8f3e5f3 100644 --- a/R/get_series_export.R +++ b/R/get_series_export.R @@ -1,6 +1,6 @@ #' Requests data from multiple data sources. #' -#' The `get_series()` function retrieves data from various sources, including the EDDS API and FRED API at this version. +#' The `get_series()` function retrieves data from various sources, including the `EDDS` API and `FRED` API at this version. #' When multiple indexes are provided as a character vector or string template, the function individually #' requests each item from the corresponding sources, discerning the source from the item's format. #' The function combines data frames when there are common frequencies and returns both a combined data frame and @@ -18,7 +18,7 @@ #' If verbose option is FALSE it gives a warning only if something goes wrong. #' @param ... Additional parameters for future versions. #' @param debug Debug option for development. -#' @param source Source such as "evds" or "fred" for internal use at this version. +#' @param source Source such as `evds` or `fred` for internal use at this version. #' @param base Table or series on the source for internal use at this version. #' @return An S3 object, Rapi_GETPREP, which has generic functions such as print and excel. #' The `print` generic provides hints to the user on how to use requested data, diff --git a/R/lag_df.R b/R/lag_df.R index 66e9f7f..9f611a9 100644 --- a/R/lag_df.R +++ b/R/lag_df.R @@ -4,10 +4,10 @@ #' and lag sequences. This feature is beneficial for scenarios where you need #' varying lag selections for certain columns, allowing flexibility in specifying #' different lags for different columns or opting for no lag at all. -#' @param df A data.frame or tibble. +#' @param df A data.frame or `tibble`. #' @param laglist A list of column names where each index corresponds to a column #' name and the associated value is the lag sequence. -#' @return tibble +#' @return `tibble` #' @export #' #' @examples @@ -26,7 +26,7 @@ as_tibblex <- function(df) { #' and lag sequences. This feature is beneficial for scenarios where you need #' varying lag selections for certain columns, allowing flexibility in specifying #' different lags for different columns or opting for no lag at all. -#' @param df A data.frame or tibble. +#' @param df A data.frame or `tibble`. #' @param laglist A list of column names where each index corresponds to a column #' name and the associated value is the lag sequence. #' @return data.frame diff --git a/R/sp_df_utils.R b/R/sp_df_utils.R index 67ea0f6..24f2eba 100644 --- a/R/sp_df_utils.R +++ b/R/sp_df_utils.R @@ -48,19 +48,19 @@ remove_column <- function(df, column_name) { #' remove_na_safe #' @description #' This function removes rows from both ends of a data frame until it identifies -#' a row where all columns have non-NA values. Starting from the beginning, it +#' a row where all columns have `non-NA` values. Starting from the beginning, it #' removes rows until it encounters a row with complete data at a specific row #' index (e.g., row 5). #' It then proceeds to remove rows from the end of the data frame, eliminating -#' any rows with at least one NA value in any column. -#' The process stops when it finds a row where all columns contain non-NA values, +#' any rows with at least one `NA` value in any column. +#' The process stops when it finds a row where all columns contain `non-NA` values, #' and the resulting data frame is returned. #' -#' @param df data.frame to remove na rows from the beginning and from the end -#' @param verbose give detailed info while removing NA values +#' @param df data.frame to remove `NA` rows from the beginning and from the end +#' @param verbose give detailed info while removing `NA` values #' #' @usage remove_na_safe(df , verbose = FALSE ) -#' @return data.frame returns data.frame after removing rows if all columns are NA +#' @return data.frame returns data.frame after removing rows if all columns are `NA` #' from the beginning and after #' @export #' @examples diff --git a/README.md b/README.md index 5a7671a..e5d1ec6 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ ## Overview Rapi package is an interface to make requests from data providers. -Current version is able to connect to APIs of [EDDS](https://evds2.tcmb.gov.tr/index.php?/evds/userDocs/) of CBRT (Central Bank of the Republic of Türkiye) +Current version is able to connect to APIs of [`EDDS`](https://evds2.tcmb.gov.tr/index.php?/evds/userDocs/) of CBRT (Central Bank of the Republic of Türkiye) and [FRED API](https://fred.stlouisfed.org/docs/api/fred/) of FED (Federal Reserve Bank). ## Installation @@ -41,7 +41,7 @@ install_github("DataRapi/Rapi") ``` r -# Set API keys for EDDS +# Set API keys for `EDDS` set_api_key("YOUR_EDDS_API_KEY", "evds", "env") # Set API keys for FRED set_api_key("YOUR_FRED_API_KEY", "fred", "env") @@ -465,12 +465,12 @@ excel(obj, "file_name.xlsx", "somefolder") ``` ## Getting API Keys -To access data from EDDS (CBRT) and FRED (FED), users need to obtain API keys by creating accounts on their respective websites. +To access data from `EDDS` (CBRT) and FRED (FED), users need to obtain API keys by creating accounts on their respective websites. -### EDDS (CBRT) API Key +### `EDDS` (CBRT) API Key -1. Visit the [EDDS (CBRT) API Documentation](https://evds2.tcmb.gov.tr/index.php?/evds/userDocs). -2. Create an account on the EDDS website if you don't have one. +1. Visit the [`EDDS` (CBRT) API Documentation](https://evds2.tcmb.gov.tr/index.php?/evds/userDocs). +2. Create an account on the `EDDS` website if you don't have one. 3. Follow the documentation to generate your API key. ### FRED (FED) API Key diff --git a/Rsearch.Rproj b/Rsearch.Rproj index a648ce1..035bfad 100644 --- a/Rsearch.Rproj +++ b/Rsearch.Rproj @@ -1,4 +1,5 @@ Version: 1.0 +ProjectId: 3ac5526f-0b5b-4729-b003-8189c4542aca RestoreWorkspace: Default SaveWorkspace: Default diff --git a/man/excel.Rd b/man/excel.Rd index 86b004e..db9b4c9 100644 --- a/man/excel.Rd +++ b/man/excel.Rd @@ -28,11 +28,11 @@ excel( \item{...}{for future versions} } \value{ -it returns object or list of data frame back +it returns object or list of \code{dataframe} back } \description{ The excel() function creates an excel file according to the object given. -data.frame or List of data frame or Rapi_GETPREP object can be passed.. +\code{data.frame} or List of data frame or \code{Rapi_GETPREP} object can be passed.. } \examples{ \dontrun{ diff --git a/man/get_series.Rd b/man/get_series.Rd index 8b8d599..46aaebe 100644 --- a/man/get_series.Rd +++ b/man/get_series.Rd @@ -38,7 +38,7 @@ If verbose option is FALSE it gives a warning only if something goes wrong.} \item{...}{Additional parameters for future versions.} -\item{source}{Source such as "evds" or "fred" for internal use at this version.} +\item{source}{Source such as \code{evds} or \code{fred} for internal use at this version.} \item{base}{Table or series on the source for internal use at this version.} @@ -50,7 +50,7 @@ The \code{print} generic provides hints to the user on how to use requested data such as creating output with the \code{excel} function or examining requested data in the global environment. } \description{ -The \code{get_series()} function retrieves data from various sources, including the EDDS API and FRED API at this version. +The \code{get_series()} function retrieves data from various sources, including the \code{EDDS} API and \code{FRED} API at this version. When multiple indexes are provided as a character vector or string template, the function individually requests each item from the corresponding sources, discerning the source from the item's format. The function combines data frames when there are common frequencies and returns both a combined data frame and diff --git a/man/lag_df.Rd b/man/lag_df.Rd index cb87fac..f45f5df 100644 --- a/man/lag_df.Rd +++ b/man/lag_df.Rd @@ -7,13 +7,13 @@ lag_df(df, laglist) } \arguments{ -\item{df}{A data.frame or tibble.} +\item{df}{A data.frame or \code{tibble}.} \item{laglist}{A list of column names where each index corresponds to a column name and the associated value is the lag sequence.} } \value{ -tibble +\code{tibble} } \description{ The \code{lag_df} function creates additional columns based on a list of column names diff --git a/man/lag_df2.Rd b/man/lag_df2.Rd index a04f894..4228339 100644 --- a/man/lag_df2.Rd +++ b/man/lag_df2.Rd @@ -7,7 +7,7 @@ lag_df2(df, laglist) } \arguments{ -\item{df}{A data.frame or tibble.} +\item{df}{A data.frame or \code{tibble}.} \item{laglist}{A list of column names where each index corresponds to a column name and the associated value is the lag sequence.} diff --git a/man/remove_na_safe.Rd b/man/remove_na_safe.Rd index 362961a..e3e66ee 100644 --- a/man/remove_na_safe.Rd +++ b/man/remove_na_safe.Rd @@ -7,22 +7,22 @@ remove_na_safe(df , verbose = FALSE ) } \arguments{ -\item{df}{data.frame to remove na rows from the beginning and from the end} +\item{df}{data.frame to remove \code{NA} rows from the beginning and from the end} -\item{verbose}{give detailed info while removing NA values} +\item{verbose}{give detailed info while removing \code{NA} values} } \value{ -data.frame returns data.frame after removing rows if all columns are NA +data.frame returns data.frame after removing rows if all columns are \code{NA} from the beginning and after } \description{ This function removes rows from both ends of a data frame until it identifies -a row where all columns have non-NA values. Starting from the beginning, it +a row where all columns have \code{non-NA} values. Starting from the beginning, it removes rows until it encounters a row with complete data at a specific row index (e.g., row 5). It then proceeds to remove rows from the end of the data frame, eliminating -any rows with at least one NA value in any column. -The process stops when it finds a row where all columns contain non-NA values, +any rows with at least one \code{NA} value in any column. +The process stops when it finds a row where all columns contain \code{non-NA} values, and the resulting data frame is returned. } \examples{ diff --git a/man/set_api_key.Rd b/man/set_api_key.Rd index 71297ee..4ba8b56 100644 --- a/man/set_api_key.Rd +++ b/man/set_api_key.Rd @@ -7,16 +7,16 @@ set_api_key(key = null, source_name = null, option = c("env", "file"), ...) } \arguments{ -\item{key}{api key of the source} +\item{key}{API key of the source} -\item{source_name}{evds or fred} +\item{source_name}{\code{evds} or \code{fred}} -\item{option}{choice of later usage. env or file should be given to -save api key for later use. Default is env which -saves api key as environment variable. -if \code{env} default value is selected it will save api key +\item{option}{choice of later usage. \code{env} or file should be given to +save API key for later use. Default is env which +saves API key as environment variable. +if \code{env} default value is selected it will save API key as an environment variable -if \code{file} was selected it will save api key to current folder.} +if \code{file} was selected it will save API key to current folder.} \item{...}{for future versions} }