Type: Package
Title: Transforming Data Between Statistical Classifications
Version: 0.1.0
Description: Provides support for transformations of numeric aggregates between statistical classifications (e.g. occupation or industry categorisations) using the 'Crossmaps' framework. Implements classes for representing transformations between a source and target classification as graph structures, and methods for validating and applying crossmaps to transform data collected under the source classification into data indexed using the target classification codes. Documentation about the 'Crossmaps' framework is provided in the included vignettes and in Huang (2024, <doi:10.48550/arXiv.2406.14163>).
License: MIT + file LICENSE
Encoding: UTF-8
Language: en-GB
Maintainer: Cynthia A. Huang <cynthiahqy@gmail.com>
URL: https://github.com/cynthiahqy/xmap, https://cynthiahqy.github.io/xmap/
BugReports: https://github.com/cynthiahqy/xmap/issues
LazyData: true
Depends: R (≥ 4.1)
Imports: cli (≥ 3.4.0), dplyr (≥ 1.1.0), methods, pillar (≥ 1.6.0), rlang (≥ 1.0.0), tibble, tidyr, tidyselect, vctrs (≥ 0.6.0)
RoxygenNote: 7.3.2
Suggests: knitr, purrr, rmarkdown, testthat (≥ 3.0.0)
Config/testthat/edition: 3
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2025-01-31 10:30:53 UTC; chua0032
Author: Cynthia A. Huang ORCID iD [aut, cre], Laura Puzzello [aut, fnd]
Repository: CRAN
Date/Publication: 2025-01-31 16:10:01 UTC

xmap: Transforming Data Between Statistical Classifications

Description

logo

Provides support for transformations of numeric aggregates between statistical classifications (e.g. occupation or industry categorisations) using the 'Crossmaps' framework. Implements classes for representing transformations between a source and target classification as graph structures, and methods for validating and applying crossmaps to transform data collected under the source classification into data indexed using the target classification codes. Documentation about the 'Crossmaps' framework is provided in the included vignettes and in Huang (2024, doi:10.48550/arXiv.2406.14163).

Author(s)

Maintainer: Cynthia A. Huang cynthiahqy@gmail.com (ORCID)

Authors:

See Also

Useful links:


Apply Crossmap Transformation to Conformable Data

Description

This function applies crossmap transformation to a dataset, transforming data based on specified mapping rules.

Usage

apply_xmap(.data, .xmap, values_from, keys_from = names(.xmap$.from), ...)

diagnose_apply_xmap(.data, .xmap, values_from, keys_from = NULL, ...)

Arguments

.data

The dataset to transform.

.xmap

An 'xmap_tbl' object.

values_from

A 'tidyselect' expression of columns in '.data' with values to transform

keys_from

A 'tidyselect' expression specifies the column in '.data' to match with '.xmap$from'

...

(reserved)

Value

A tibble with transformed data.

Functions

Examples

abc_xmap <- demo$abc_links |>
  as_xmap_tbl(from = "lower", to = "upper", weight_by = "share")
abc_data <- tibble::tibble(
  lower = unique(demo$abc_links$lower),
  count = runif(length(unique(demo$abc_links$lower)), min = 100, max = 500)
)
apply_xmap(
  .data = abc_data,
  .xmap = abc_xmap,
  values_from = count
)

Coercing data frames of links to crossmap tibbles

Description

This method takes a data.frame-like object and converts it into an 'xmap_tbl' based on specified columns for 'from', 'to', and 'weight'.

Usage

as_xmap_tbl(x, ...)

## S3 method for class 'data.frame'
as_xmap_tbl(x, from, to, weight_by, ..., tol = .Machine$double.eps^0.5)

diagnose_as_xmap_tbl(
  x,
  from,
  to,
  weight_by,
  ...,
  tol = .Machine$double.eps^0.5
)

Arguments

x

A data.frame or tibble to be converted in a crossmap tibble.

...

(reserved) Additional arguments passed to methods.

from

The column in ‘x' that specifies the ’from' nodes.

to

The column in ‘x' that specifies the ’to' nodes.

weight_by

The column in 'x' that specifies the weight of the links.

tol

Tolerance of comparison.

Value

Returns an xmap tibble object.

Examples

demo$abc_links |>
  as_xmap_tbl(from = lower, to = upper, weight_by = share)

Demo objects for the 'xmap' package

Description

A collection of demo inputs for experimenting with functions in the 'xmap' package. '_pairs' objects are tibbles with just source-target *pairs* (no weights) '_links' objects are tibbles with weighted source-target *links*.

Usage

demo

Format

## 'demo' A list with:

ctr_iso3c_pairs

named vector with 249 elements. Names are ISO-3 country codes, values are ISO English country names. Retrieved from 'countrycode' package: https://github.com/vincentarelbundock/countrycode

anzsco22_isco8_crosswalk

tibble with 10 rows and 5 columns. Subset of crosswalk between ANZSCO22 and ISCO8 Occupation Code Standards published by The AUstralian Bureau of Statistics

anzsco22_stats

tibble with 10 rows and 2 columns. Stylised Occupation Counts

simple_links

tibble with 10 rows and 3 columns. specifying links 'xcode'->'alphacode' by 'weight'

abc_links

tibble with 6 rows and 3 columns, specifying links 'lower'->'upper' by 'share'

aus_state_pairs

named list with 1 element named "AUS" containing codes for the Australian states

aus_state_pop_df

tibble containing 2022 population figures for Australia by state. Retrieved from: https://www.abs.gov.au/statistics/people/population/national-state-and-territory-population/jun-2022

Examples

demo$abc_links

Boolean flags for properties of candidate and validated xmap links (internal)

Description

'vhas_*()' functions check properties of xmap links and/or candidate links. The functions only accepts equal length vector inputs to support multiple link formats, but does not check if the inputs are from the same xmap.

Usage

vhas_no_dup_pairs(v_from, v_to)

vhas_valid_weights(v_from, v_weights, tol = .Machine$double.eps^0.5)

Arguments

v_from, v_to, v_weights

equal length vectors containing the source-target node pairs

tol

numeric \ge 0. Ignore differences smaller than 'tol'. Passed through to the 'tolerance' arg of 'base::all.equal()'.

Value

TRUE or FALSE

Functions


Internal rlang methods

Description

Internal rlang methods


Internal vctrs methods

Description

Internal vctrs methods