Learn R Programming

tfse (version 0.5.0)

cc: Combine comma separated strings

Description

Split strings by comma into character vector(s)

Usage

cc(x, simplify)

Arguments

x

Vector of comma separated character strings

simplify

Logical indicating whether to return a character vector (the default) when the length of x is one. This argument does nothing if the length of x is greater than 1.

Value

If length of x is 1 then a character vector otherwise a list of character vectors.

Examples

Run this code
# NOT RUN {
## comma separated alphabet
abcs <- paste(letters, collapse = ",")

## split single string
cc(abcs)

## return as list
cc(abcs, simplify = FALSE)

## select columns
mtcars[, cc("cyl,mpg,wt,gear")]

## character vector with multiple strings
x <- c("v1,v2,v3", "y1,y2,y5")

## convert strings into list of [split] character vectors
cc(x)

# }

Run the code above in your browser using DataLab