Learn R Programming

iotables (version 0.9.4)

vector_transpose_wider: Transpose a Vector to Wide Form

Description

Convert a long-form vector (e.g., indicators, multipliers) into wide form, which is often more useful for binding with input–output tables. This is a thin wrapper around tidyr::pivot_wider(), provided so you do not need to load tidyr explicitly.

Usage

vector_transpose_wider(
  data_table,
  names_from,
  values_from,
  key_column_name = NULL,
  key_column_values = NULL
)

Arguments

data_table

A data.frame or tibble, normally with a key column. If the key column must be created or replaced, use key_column_name and key_column_values.

names_from, values_from

Columns specifying the names of the output columns (names_from) and the values to fill (values_from).

key_column_name

The name of the key column.

key_column_values

Optional explicit key column values. Default: NULL, in which case values are inferred from the long data.

See Also

Other iotables processing functions: conforming_vector_create(), empty_remove(), household_column_find(), household_column_get(), iotable_year_get(), key_column_create(), matrix_round(), output_get(), primary_input_get(), rows_add(), supplementary_add(), total_tax_add(), vector_transpose_longer()

Examples

Run this code
vector_transpose_wider(
  data_table = germany_airpol[, -2],
  names_from = "induse",
  values_from = "value"
)

vector_transpose_wider(
  data_table = germany_airpol[1:8, 3:4],
  names_from = "induse",
  values_from = "value",
  key_column_values = "CO2_emission"
)

Run the code above in your browser using DataLab