Learn R Programming

iotables (version 0.9.4)

vector_transpose_longer: Transpose a Vector to Long Form

Description

Convert a wide-form vector (e.g., indicators or multipliers) into long form, which is often more useful for printing or joining. This is a thin wrapper around tidyr::pivot_longer(), provided so you do not need to load tidyr explicitly.

Usage

vector_transpose_longer(
  data_table,
  names_to = "nace_r2",
  values_to = "value",
  key_column_name = NULL,
  .keep = FALSE
)

vector_transpose( data_table, names_to = "nace_r2", values_to = "value", key_column_name = NULL, .keep = FALSE )

Value

A tibble in long format with a key column and, if requested, the indicator identifier column.

Arguments

data_table

A data.frame or tibble. The first column is assumed to be a key column.

names_to

Name of the new column containing previous column names. Default: "nace_r2".

values_to

Name of the new column containing the values. Default: "value".

key_column_name

Optional. New name for the first (key) column. If NULL (default), the name is not changed.

.keep

Logical. If TRUE, keep the indicator identifier column. If FALSE (default), drop it.

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_wider()

Examples

Run this code
vector_transpose_longer(
  data.frame(
    indicator = "my_indicator",
    agriculture = 0.0123,
    manufacturing = 0.1436,
    trade = 0.0921
  )
)

# Keep the indicator column
vector_transpose_longer(
  data.frame(
    indicator = "my_indicator",
    agriculture = 0.0123,
    manufacturing = 0.1436
  ),
  .keep = TRUE
)

Run the code above in your browser using DataLab