ir
object by adding new or replacing existing columnsMutate an ir
object by adding new or replacing existing columns
mutate.ir(
.data,
...,
.keep = c("all", "used", "unused", "none"),
.before = NULL,
.after = NULL
)transmute.ir(.data, ...)
.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
.
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.
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.
<tidy-select
> Optionally, control where new columns
should appear (the default is to add to the right hand side). See
relocate()
for more details.
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()
## mutate
dplyr::mutate(ir_sample_data, hkl = klason_lignin + holocellulose)
## transmute
dplyr::transmute(ir_sample_data, hkl = klason_lignin + holocellulose)
Run the code above in your browser using DataLab