cbs_add_unit_column: For each topic column add a unit column

View source: R/cbs_add_unit_column.R

cbs_add_unit_columnR Documentation

For each topic column add a unit column

Description

Adds extra unit columns to the dataset that was retrieved using cbs_get_data().

Usage

cbs_add_unit_column(x, columns = colnames(x), ...)

Arguments

x

data.frame retrieved using cbs_get_data().

columns

character with the names of the columns for which units will be added, non-topic columns will be ignored.

...

not used.

Details

The unit columns will be named ⁠<topic_column>_unit⁠, and are a character

By default all topic columns will be with a unit column. The name of each unit column will be ⁠<topic_column>_unit⁠.

Value

the original data.frame x with extra unit columns. (see description)

See Also

Other data retrieval: cbs_add_date_column(), cbs_add_label_columns(), cbs_download_data(), cbs_extract_table_id(), cbs_get_data(), cbs_get_data_from_link()

Other meta data: cbs_add_date_column(), cbs_add_label_columns(), cbs_download_meta(), cbs_get_meta()

Examples

if (interactive()) {
  x <- cbs_get_data( id      = "7196ENG"      # table id
                   , Periods = "2000MM03"     # March 2000
                   , CPI     = "000000"       # Category code for total 
                   , verbose = TRUE           # show the url that is used
                   )
  
  
  # adds two extra columns
  x_with_units <- 
    x |> 
    cbs_add_unit_column()
  
  x_with_units[,1:4]
}

edwindj/cbsodataR documentation built on Oct. 17, 2024, 3:35 a.m.