dm_disambiguate_cols {dm}R Documentation

Resolve column name ambiguities

Description

This function ensures that all columns in a dm have unique names.

Usage

dm_disambiguate_cols(
  dm,
  .sep = ".",
  ...,
  .quiet = FALSE,
  .position = c("suffix", "prefix")
)

Arguments

dm

A dm object.

.sep

The character variable that separates the names of the table and the names of the ambiguous columns.

...

These dots are for future extensions and must be empty.

.quiet

Boolean. By default, this function lists the renamed columns in a message, pass TRUE to suppress this message.

.position

[Experimental] By default, table names are appended to the column names to resolve conflicts. Prepending table names was the default for versions before 1.0.0, use "prefix" to achieve this behavior.

Details

The function first checks if there are any column names that are not unique. If there are, those columns will be assigned new, unique, names by prefixing their existing name with the name of their table and a separator. Columns that act as primary or foreign keys will not be renamed because only the foreign key column will remain when two tables are joined, making that column name "unique" as well.

Value

A dm whose column names are unambiguous.

Examples


dm_nycflights13() %>%
  dm_disambiguate_cols()


[Package dm version 1.0.10 Index]