split_columns: Split columns on basis of a string and duplicate entries

View source: R/split_columns.R

split_columnsR Documentation

Split columns on basis of a string and duplicate entries

Description

Based on stringi::stri_split_fixed() column names are split on basis of a split pattern into new columns. The content of the original column is duplicated in all split columns.

Usage

split_columns(x, pattern)

Arguments

x

A data.frame or data.table.

pattern

The pattern to split the columns (will not be included in the new column names).

Value

Dependding on the input class, a data.frame or data.table with the additional columns.

Examples

df <- data.frame(split_here = 11:13, and_here = letters[11:13],  and_again_here = 14:16)
split_columns(df, "_")
#   split here and here and again here
# 1    11   11   k    k  14    14   14
# 2    12   12   l    l  15    15   15
# 3    13   13   m    m  16    16   16

manuelbickel/textility documentation built on Nov. 25, 2022, 9:07 p.m.