mutate {ir}R Documentation

Mutate an ir object by adding new or replacing existing columns

Description

Mutate an ir object by adding new or replacing existing columns

Usage

mutate.ir(
  .data,
  ...,
  .keep = c("all", "used", "unused", "none"),
  .before = NULL,
  .after = NULL
)

transmute.ir(.data, ...)

Arguments

.data

An object of class ir.

...

<data-masking> Name-value pairs. The name gives the name of the column in the output.

The value can be:

  • A vector of length 1, which will be recycled to the correct length.

  • A vector the same length as the current group (or the whole data frame if ungrouped).

  • NULL, to remove the column.

  • A data frame or tibble, to create multiple columns in the output.

.keep

[Experimental] Control which columns from .data are retained in the output. Grouping columns and columns created by ... are always kept.

  • "all" retains all columns from .data. This is the default.

  • "used" retains only the columns used in ... to create new columns. This is useful for checking your work, as it displays inputs and outputs side-by-side.

  • "unused" retains only the columns not used in ... to create new columns. This is useful if you generate new columns, but no longer need the columns used to generate them.

  • "none" doesn't retain any extra columns from .data. Only the grouping variables and columns created by ... are kept.

.before, .after

[Experimental] <tidy-select> Optionally, control where new columns should appear (the default is to add to the right hand side). See relocate() for more details.

Value

.data with modified columns. If the spectra column is dropped or invalidated (see ir_new_ir()), the ir class is dropped, else the object is of class ir.

Source

dplyr::mutate()

See Also

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

Examples

## mutate
dplyr::mutate(ir_sample_data, hkl = klason_lignin + holocellulose)


## transmute
dplyr::transmute(ir_sample_data, hkl = klason_lignin + holocellulose)



[Package ir version 0.2.1 Index]