Learn R Programming

pliman (version 2.1.0)

separate_col: Turns a single character column into multiple columns.

Description

Given either a regular expression or a vector of character positions, separate_col() turns a single character column into multiple columns.

Usage

separate_col(.data, col, into, sep = "[^[:alnum:]]+")

Value

A mutated .data

Arguments

.data

A data frame

col

Column name

into

Names of new variables to create as character vector

sep

The separator between columns. By default, a regular expression that matches any sequence of non-alphanumeric values.

Examples

Run this code
library(pliman)
df <- data.frame(x = paste0("TRAT_", 1:5),
                 y = 1:5)
df
separate_col(df, x, into = c("TRAT", "REP"))

Run the code above in your browser using DataLab