camr_column_abbreviations: Abbreviations and Labels for Column Names

View source: R/R07-Codebook.R

camr_column_abbreviationsR Documentation

Abbreviations and Labels for Column Names

Description

Function to match labels describing variable categories and data types to abbreviations contained within a column name.

Usage

camr_column_abbreviations(
  column_name = "",
  type = NULL,
  custom = NULL,
  n = NA,
  separator = "."
)

Arguments

column_name

A standardized variable name (i.e., 'GGG.TTT.Var_name' or 'GGG.TTT.Optional.Var_name').

type

The type of abbreviation whose label is to be extracted.

custom

An optional matrix with two columns, 'Abbr' and 'Label', for custom abbreviations and labels, respectively.

n

The number of rows to create when generating a template for the matrix to pass to the custom argument.

separator

The punctuation used to separate abbreviations, typically a period.

Value

A character string. If only n is provided, a matrix with n rows with columns 'Abbr' and 'Label' to use as a template for custom abbreviations/labels.

Author(s)

Kevin Potter

Examples

# List pre-defined abbreviations and labels
camr_column_abbreviations( type = 'category' )
camr_column_abbreviations( type = 'data type' )

# Match abbreviation for variable categories
camr_column_abbreviations(
  'IDS.CHR.Subject', type = 'category'
)

# Match abbreviation for data type
camr_column_abbreviations(
  'IDS.CHR.Subject', type = 'data type'
)

# Create template for custom abbreviations
# and labels
M <- camr_column_abbreviations( n = 3 )
M[,1] <- c( 'BL', 'Y1', 'Y2' )
M[,2] <- c( 'Baseline', 'Year 1', 'Year 2' )
camr_column_abbreviations( 'SMK.INT.BL.Quit_status', custom = M )
camr_column_abbreviations( 'SMK.INT.Y2.Quit_status', custom = M )


rettopnivek/camrprojects documentation built on March 26, 2024, 9:17 a.m.