cc: Combine comma separated strings

Description Usage Arguments Value Examples

Description

Split strings by comma into character vector(s)

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## 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)

mkearney/tfse documentation built on July 6, 2019, 3:18 a.m.