
Last chance! 50% off unlimited learning
Sale ends in
data.frame
, split on that delimiter. A nice wrapper
to strsplit
, essentially - the primary bonus
is the automatic coersion to a data.frame
.
str_split(x, sep, fixed = FALSE, perl = TRUE, useBytes = FALSE, names = NULL)
split2df(x, sep, fixed = FALSE, perl = TRUE, useBytes = FALSE, names = NULL)
regex
you wish
to split your strings on.TRUE
, we match sep
exactly; otherwise, we use regular expressions. Has
priority over perl
.fixed
is TRUE
.TRUE
, matching is done
byte-by-byte rather than character-by-character.data.frame
.read.table(text=...)
or data.table::fread
;
however, this function is helpful in the case of
non-regular delimiters (that you wish to specify with a
regex)
strsplit
str_split(
c("regular_structure", "in_my", "data_here"),
sep="_",
names=c("apple", "banana")
)
x <- c("somewhat_different.structure", "in_this.guy")
str_split( x, "[_\\.]", names=c("first", "second", "third") )
Run the code above in your browser using DataLab