Skip to content
Merged

Dev #101

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
#
# NOTE: This workflow is overkill for most R packages and
# check-standard.yaml is likely a better choice.
# usethis::use_github_action("check-standard") will install it.
on:
push:
branches: [main, master, dev]
branches: [main, dev]
pull_request:
branches: [main, master, dev]

name: R-CMD-check
name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
Expand All @@ -19,17 +24,24 @@ jobs:
matrix:
config:
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
# use 4.0 or 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: 'oldrel-4'}

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
- {os: ubuntu-latest, r: 'oldrel-4'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -47,3 +59,4 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
49 changes: 49 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, dev]
pull_request:
release:
types: [published]
workflow_dispatch:

name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
clean: false
branch: gh-pages
folder: docs
19 changes: 0 additions & 19 deletions .github/workflows/recheck.yaml

This file was deleted.

95 changes: 0 additions & 95 deletions .github/workflows/rhub.yaml

This file was deleted.

18 changes: 10 additions & 8 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master,dev]
branches: [main, dev]
pull_request:
branches: [main, master,dev]

name: test-coverage
branches: [main, dev]
name: test-coverage.yaml

permissions: read-all

Expand Down Expand Up @@ -35,14 +35,16 @@ jobs:
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
print(cov)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
# Fail if error if not on PR, or if on PR and token is given
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
files: ./cobertura.xml
plugins: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ test_package.R
inst/doc
/doc/
/Meta/

/.quarto/
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: comtradr
Title: Interface with the United Nations Comtrade API
Version: 1.0.4
Version: 1.0.4.9000
Maintainer: Paul Bochtler <paulbochtler.gh@gmail.com>
Authors@R: c(
person("Paul", "Bochtler",
Expand Down Expand Up @@ -68,7 +68,7 @@ Suggests:
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
URL: https://docs.ropensci.org/comtradr/, https://github.com/ropensci/comtradr
BugReports: https://github.com/ropensci/comtradr/issues
NeedsCompilation: no
Expand Down
19 changes: 19 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# comtradr 1.0.5 (or your next version number)

## New Features

* Added `available_variables` to `ct_get_ref_table()` to query comprehensive
metadata about all Comtrade API variables. Returns variable descriptions,
original API field names, and tidy column names in a single table. This makes
it easy to:
- Understand what each column in trade data represents
- Create data dictionaries for documentation
- Map between original and tidy column names
- Build visualizations with proper variable labels
Example: `ct_get_ref_table("available_variables")` (#XXX).

## Minor improvements

* Enhanced documentation for reference tables
* Added comprehensive tests for variable metadata functionality

# comtradr 1.0.4

* patched ct_get_ref_table to also return reporterCodeIsoAlpha2 and partnerCodeIsoAlpha2, see: https://github.com/ropensci/comtradr/issues/94
Expand Down
27 changes: 25 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ ct_migrate_cache <- function(){
#' * 'mode_of_transport'
#' * 'customs_code'
#' * 'flow_direction'
#' * 'frequency'
#' * 'mode_of_supply'
#' * 'units_of_quantity'
#' * 'available_variables'
#'
#' @param dataset_id The dataset ID, which is either partner,
#' reporter or a valid classification scheme.
Expand Down Expand Up @@ -166,7 +170,11 @@ ct_get_ref_table <- function(dataset_id, update = FALSE, verbose = FALSE) {
"partner" = "partner",
"mode_of_transport" = "mot",
"flow_direction" = "flow",
"customs_code" = "customs"
"customs_code" = "customs",
"frequency" = "freq",
"mode_of_supply" = "mos",
"units_of_quantity" = "qtyunit",
"available_variables" = "dataitem"
)

## check dataset id for valid values
Expand All @@ -188,6 +196,14 @@ ct_get_ref_table <- function(dataset_id, update = FALSE, verbose = FALSE) {
assign(dataset_id, data, envir = ct_env)
}

## add pretty cols
if (dataset_id == "available_variables") {
data <- data |>
poorman::left_join(
comtradr::ct_pretty_cols,
by = c("dataItem" = "from")
)
}
if (update & any(dataset_id %in% ct_env$updated)) {
## if update is true, but dataset_id has already been updated once
## only return message
Expand All @@ -209,7 +225,14 @@ ct_get_ref_table <- function(dataset_id, update = FALSE, verbose = FALSE) {
}

## download new reference table from the UN
data_new <- ct_download_ref_table(ref_table_id = ref_table_id)
data_new <- ct_download_ref_table(ref_table_id = ref_table_id)
if(dataset_id == "available_variables"){
data_new <- data_new |>
poorman::left_join(
comtradr::ct_pretty_cols,
by = c("dataItem" = "from"))
}


if (unique(data_new$last_modified) > unique(data$last_modified)) {
## if the date last modified, returned in
Expand Down
6 changes: 5 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ assign("B4", NULL, envir = ct_env)
assign("B5", NULL, envir = ct_env)
assign("EB02", NULL, envir = ct_env)
assign("EB10", NULL, envir = ct_env)
assign("EB10s", NULL, envir = ct_env)
assign("EB10S", NULL, envir = ct_env)
assign("EB", NULL, envir = ct_env)
assign("H0", NULL, envir = ct_env)
assign("H1", NULL, envir = ct_env)
Expand All @@ -104,6 +104,10 @@ assign("S3", NULL, envir = ct_env)
assign("S4", NULL, envir = ct_env)
assign("SS", NULL, envir = ct_env)
assign("mode_of_transport", NULL, envir = ct_env)
assign("mode_of_supply", NULL, envir = ct_env)
assign("available_variables", NULL, envir = ct_env)
assign("units_of_quantity", NULL, envir = ct_env)
assign("frequency", NULL, envir = ct_env)
assign("customs_code", NULL, envir = ct_env)
assign("flow_direction", NULL, envir = ct_env)
assign("reporter", NULL, envir = ct_env)
Expand Down
Loading