rename {ir}R Documentation

Rename columns in ir objects

Description

Rename columns in ir objects

Usage

rename.ir(.data, ...)

rename_with.ir(.data, .fn, .cols = dplyr::everything(), ...)

Arguments

.data

An object of class ir.

...

For rename(): <tidy-select> Use new_name = old_name to rename selected variables.

For rename_with(): additional arguments passed onto .fn.

.fn

A function used to transform the selected .cols. Should return a character vector the same length as the input.

.cols

<tidy-select> Columns to rename; defaults to all columns.

Value

.data with renamed columns. If the spectra column is renamed, and no new valid spectra column is created, the ir class is dropped, else the object is of class ir.

Source

dplyr::rename()

See Also

Other tidyverse: arrange.ir(), distinct.ir(), extract.ir(), filter-joins, filter.ir(), group_by, mutate-joins, mutate, nest, pivot_longer.ir(), pivot_wider.ir(), rowwise.ir(), select.ir(), separate.ir(), separate_rows.ir(), slice, summarize, unite.ir()

Examples

## rename
dplyr::rename(ir_sample_data, hol = "holocellulose")
dplyr::rename(ir_sample_data, spec = "spectra") # drops ir class


## rename_with
dplyr::rename_with(ir_sample_data, .cols = dplyr::starts_with("id_"),
  toupper)
dplyr::rename_with(ir_sample_data, toupper) # drops ir class



[Package ir version 0.2.1 Index]