pivot_wider.ir {ir} | R Documentation |
Pivot an ir
object from wide to long
Description
Pivot an ir
object from wide to long
Usage
pivot_wider.ir(
data,
id_cols = NULL,
names_from = "name",
names_prefix = "",
names_sep = "_",
names_glue = NULL,
names_sort = FALSE,
names_repair = "check_unique",
values_from = "value",
values_fill = NULL,
values_fn = NULL,
...
)
Arguments
data |
An object of class |
id_cols |
< |
names_from , values_from |
< If |
names_prefix |
String added to the start of every variable name. This is
particularly useful if |
names_sep |
If |
names_glue |
Instead of |
names_sort |
Should the column names be sorted? If |
names_repair |
What happens if the output has invalid column names?
The default, |
values_fill |
Optionally, a (scalar) value that specifies what each
This can be a named list if you want to apply different fill values to different value columns. |
values_fn |
Optionally, a function applied to the value in each cell
in the output. You will typically use this when the combination of
This can be a named list if you want to apply different aggregations
to different |
... |
Additional arguments passed on to methods. |
Value
data
in a wide format. 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
See Also
Other tidyverse:
arrange.ir()
,
distinct.ir()
,
extract.ir()
,
filter-joins
,
filter.ir()
,
group_by
,
mutate-joins
,
mutate
,
nest
,
pivot_longer.ir()
,
rename
,
rowwise.ir()
,
select.ir()
,
separate.ir()
,
separate_rows.ir()
,
slice
,
summarize
,
unite.ir()
Examples
## pivot_wider
ir_sample_data %>%
tidyr::pivot_longer(
cols = dplyr::any_of(c("holocellulose", "klason_lignin"))
) %>%
tidyr::pivot_wider(names_from = "name", values_from = "value")