Creating variables by splitting the elements of a character vector without needing a split string
AutoSplit(
s,
split = NULL,
border = "_",
revBorder = FALSE,
noSplit = FALSE,
varNames = paste("var", 1:100, sep = ""),
tryReverse = TRUE
)
The character vector
Split string. When NULL (default), automatic splitting without a split string.
A split character or an integer (move split) to be used when the exact split position is not unique.
When border is integer the split position is moved from the other side.
No splitting when TRUE.
Variable names of the created variables (too many is ok)
When TRUE, the automatic method tries to find more variables by splitting from reversed strings.
A data frame with s as row names.
# NOT RUN {
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"))
# }
Run the code above in your browser using DataLab