Rename an object based on case-insensitive match of the names of a reference.

rename_matches(x, y)

Arguments

x

x object which names to restored if they match the reference.

y

Named object to use as reference.

Value

The output is x with as many names changed as case-insensitive matches there are with the reference.

See also

Other functions for developers: check_crucial_names(), extract_insensitive(), flag_if_group(), is_multiple(), nms_try_rename(), type_ensure()

Other general functions to deal with names: extract_insensitive()

Examples

ref <- data.frame(COL1 = 1, COL2 = 1)
x <- data.frame(col1 = 5, col2 = 1, n = 5)
rename_matches(x, ref)
#>   COL1 COL2 n
#> 1    5    1 5