df_explode | R Documentation |
Split/explode a data frame character column into multiple columns.
This is done by splitting the string by one or multiple delimiters. The split
results are wrapped in a data.frame
and “cbinded” to x
.
Optionally, one can pass column names and/or types for the parts. E.g.
types="cir"
converts the first part into character, the second into
integer and the third into real/double.
df_explode(x, split.col, split, names = NULL, types = NULL, keep = FALSE)
x |
[ |
split.col |
[ |
split |
[ |
names |
[ |
types |
[ |
keep |
[ |
Modified data frame.
Other data frame helpers:
df_add_category()
,
df_add_constant_columns()
,
df_rows_to_list()
,
df_split_col()
x = data.frame(a = c("x-y-1", "a-b-2", "c-d-3"), b = 1:3, c = runif(3))
df_explode(x, split.col = "a", split = "-")
df_explode(x, split.col = "a", split = "-", keep = TRUE)
df_explode(x, split.col = "a", split = "-", names = c("A", "B", "C"))
df_explode(x, split.col = "a", split = "-", types = "cci")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.