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

Description Usage Arguments Value Author(s) Examples

View source: R/AutoSplit.r

Description

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

Usage

1
2
3
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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"))

statisticsnorway/SSBtools documentation built on March 3, 2020, 1:34 a.m.