AutoSplit: Creating variables by splitting the elements of a character...

View source: R/AutoSplit.r

AutoSplitR Documentation

Creating variables by splitting the elements of a character vector without needing a split string

Description

Creating variables by splitting the elements of a character vector without needing a split string

Usage

AutoSplit(
  s,
  split = NULL,
  border = "_",
  revBorder = FALSE,
  noSplit = FALSE,
  varNames = paste("var", 1:100, sep = ""),
  tryReverse = TRUE
)

Arguments

s

The character vector

split

Split string. When NULL (default), automatic splitting without a split string.

border

A split character or an integer (move split) to be used when the exact split position is not unique.

revBorder

When border is integer the split position is moved from the other side.

noSplit

No splitting when TRUE.

varNames

Variable names of the created variables (too many is ok)

tryReverse

When TRUE, the automatic method tries to find more variables by splitting from reversed strings.

Value

A data frame with s as row names.

Author(s)

Øyvind Langsrud

Examples

s <- c("A12-3-A-x","A12-3-B-x","B12-3-A-x","B12-3-B-x",
       "A12-3-A-y","A12-3-B-y","B12-3-A-y","B12-3-B-y")
AutoSplit(s)
AutoSplit(s,border="-")
AutoSplit(s,split="-")
AutoSplit(s,border=1)
AutoSplit(s,border=2)
AutoSplit(s,border=2,revBorder=TRUE)
AutoSplit(s,noSplit=TRUE)
AutoSplit(s,varNames=c("A","B","C","D"))

SSBtools documentation built on Oct. 30, 2024, 5:09 p.m.

Related to AutoSplit in SSBtools...