Learn R Programming

ir (version 0.4.1)

rename: Rename columns in ir objects

Description

Rename columns in ir objects

Usage

rename.ir(.data, ...)

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

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.

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.

See Also

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

Examples

Run this code
## 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


Run the code above in your browser using DataLab