renameColumns {PDATK} | R Documentation

## Rename columns or do nothing if the names don't match

### Description

Rename columns or do nothing if the names don't match

### Usage

    renameColumns(x, values)

### Arguments

`x` | An object for which `colnames` is defined, probably a `data.frame` or other similar object.
`values` | A character vector where names are the old column names and values are the new column names. Uses `gsub` internally to do the renaming.

### Value

`x` with the updated column names if they are present. Does not fail if the column names are missing.

### Examples

    x <- data.frame(a=factor(LETTERS[1:5]), b=factor(runif(5, 0, 1)))
    renameColumns(x, c(a='c'))

[Package PDATK version 1.2.0 Index]