Skip to contents

This is useful for DTA export since Stata has a built-in variable name length limit of 32 characters (see also here).

Usage

shorten_colnames(x, max_n_char = 32L)

Arguments

x

A tabular data object like a data frame or tibble.

max_n_char

Maximum allowed number of characters. It is ensured that the maximum resulting variable name length doesn't exceed this limit. Has no influence on the applied shortening logic. An integerish scalar or Inf for no limit.

Value

x with column names shortened to a maximum length of 32 characters.

See also

Other variable name shortening functions: restore_colnames(), shorten_var_names()