MIT License + +Copyright (c) 2023 HanjoStudy + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. ++ +
The quantec library is a wrapper around the EasyData data portal from Quantec maintained by the Bureau for Economic Research.
+This is the homepage for the {quantec} R package https://github.com/Bureau-for-Economic-Research/quantec.
+NOTE: The API is currently in BETA testing.
+💡 Please be a good digital citizen when interacting with an API - restrict parallel implementation and institute sleeps between calling data.
+This package is no way endorsed by Quantec and was developed at the Bureau for Economic Research in order to streamline research process.
+From the Quantec Website
+Quantec is a consultancy providing economic and financial data, country intelligence and quantitative analytical software.
+Please reach out to Quantec via there Contact Page https://www.quantec.co.za/contact/ to receive an API key.
+Install from GitHub.
+
+remotes::install_github("Bureau-for-Economic-Research/quantec")
If you want availability to the latest features (at your own risk) then you can also install from the development branch.
+
+remotes::install_github("Bureau-for-Economic-Research/quantec", ref = "dev")
+library(quantec)
Check version.
+
+packageVersion("quantec")
To access the API you’ll need to first specify an API in your .Renviron
key as provided to you by Quantec.
.Renviron
+Sys.setenv(QUANTEC_API="place_your_key_here")
+Sys.getenv("QUANTEC_API")
The package currently provides an interface to the Quantec data API. The function quantec_get_data
has the following options:
time_series_code
time series code to return, NMS-EC_BUS,NMS-GA_BUS
+freq
frequency to return M
, Q
or A
+start_year
year to startend_year
year to endrespformat
to return csv
or json
+log_file
log file to output to if in parallelis_tidy
tidyformat for easy read
+library(quantec)
+library(logger)
+
+quantec_get_data(time_series_code = "NMS-EC_BUS",
+ freq = "A",
+ start_year = 2000,
+ end_year = 2022)
+
+# A tibble: 29 × 6
+# title unit source code date value
+# <chr> <chr> <chr> <chr> <date> <dbl>
+# 1 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 1994-12-31 10
+# 2 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 1995-12-31 7
+# 3 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 1996-12-31 28
+# 4 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 1997-12-31 70
+# 5 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 1998-12-31 7
+# 6 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 1999-12-31 3
+# 7 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 2000-12-31 6
+# 8 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 2001-12-31 25
+# 9 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 2002-12-31 53
+# 10 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 2003-12-31 17
+# ℹ 19 more rows
+# ℹ Use `print(n = ...)` to see more rows
If you want to turn on the logging:
+
+library(quantec)
+library(logger)
+
+log_threshold(level = DEBUG)
+quantec_get_data(time_series_code = "NMS-EC_BUS",
+ freq = "A",
+ start_year = 2000,
+ end_year = 2022)
+
+# DEBUG [2023-09-20 14:10:46] [NMS-EC_BUS] -- Querying with parameters: # [{"timeSeriesCodes":["NMS-EC_BUS"],"respFormat":["csv"],"freqs":["A"],"startYear":[2000],"endYear":[2022],"isTidy":[true]}]
+# DEBUG [2023-09-20 14:10:46] [NMS-EC_BUS] -- Found 29 rows
+# A tibble: 29 × 6
+# title unit source code date value
+# <chr> <chr> <chr> <chr> <date> <dbl>
+# 1 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 1994-12-31 10
+# 2 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 1995-12-31 7
+# 3 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 1996-12-31 28
+# 4 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 1997-12-31 70
+# 5 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 1998-12-31 7
+# 6 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 1999-12-31 3
+# 7 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 2000-12-31 6
+# 8 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 2001-12-31 25
+# 9 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 2002-12-31 53
+# 10 SACU domestic sales - South Africa - Eastern Cape: Bus sales (> 8,500kg) Number (Sum of Monthly Values) NAAMSA NMS-EC_BUS-SAN 2003-12-31 17
+# ℹ 19 more rows
+# ℹ Use `print(n = ...)` to see more rows