ir
object into multiple columns with a regular expression or numeric locationsSeparate a character column in an ir
object into multiple columns with a regular expression or numeric locations
separate.ir(
data,
col,
into,
sep = "[^[:alnum:]]+",
remove = TRUE,
convert = FALSE,
extra = "warn",
fill = "warn",
...
)
.data
with separated 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
.
<tidy-select
> Column to expand.
Names of new variables to create as character vector.
Use NA
to omit the variable in the output.
Separator between columns.
If character, sep
is interpreted as a regular expression. The default
value is a regular expression that matches any sequence of
non-alphanumeric values.
If numeric, sep
is interpreted as character positions to split at. Positive
values start at 1 at the far-left of the string; negative value start at -1 at
the far-right of the string. The length of sep
should be one less than
into
.
If TRUE
, remove input column from output data frame.
If TRUE
, will run type.convert()
with
as.is = TRUE
on new columns. This is useful if the component
columns are integer, numeric or logical.
NB: this will cause string "NA"
s to be converted to NA
s.
If sep
is a character vector, this controls what
happens when there are too many pieces. There are three valid options:
"warn"
(the default): emit a warning and drop extra values.
"drop"
: drop any extra values without a warning.
"merge"
: only splits at most length(into)
times
If sep
is a character vector, this controls what
happens when there are not enough pieces. There are three valid options:
"warn"
(the default): emit a warning and fill from the right
"right"
: fill with missing values on the right
"left"
: fill with missing values on the left
Additional arguments passed on to methods.
Other tidyverse:
arrange.ir()
,
distinct.ir()
,
extract.ir()
,
filter-joins
,
filter.ir()
,
group_by
,
mutate
,
mutate-joins
,
nest
,
pivot_longer.ir()
,
pivot_wider.ir()
,
rename
,
rowwise.ir()
,
select.ir()
,
separate_rows.ir()
,
slice
,
summarize
,
unite.ir()
## separate
ir_sample_data |>
tidyr::separate(
col = "id_sample", c("a", "b", "c")
)
Run the code above in your browser using DataLab