StrChop

0th

Percentile

Split a String in a Number of Pieces With Fixed Length

Split a string in a number of pieces with fixed length

Keywords
character
Usage
StrChop(x, len, pos)
Arguments
x
the string to be cut in pieces.

len
a vector with the lengths of the pieces.
pos
a vector of cutting positions. This can not be used simultaneously with len.
Details

If length is going over the end of the string the last part will be returned, so if the rest of the string is needed, it's possible to simply enter a big number as last partlength.

len and pos can't be defined simultaneously, only alternatively.

Typical usages are

StrChop(x, len)
StrChop(x, pos)

Value

See Also

FixToTab

Aliases
  • StrChop
Examples
x <- paste(letters, collapse="")
StrChop(x=x, len = c(3,5,2))

# and with the rest integrated
StrChop(x=x, len = c(3, 5, 2, nchar(x)))

# cutpoints at 5th and 10th position
StrChop(x=x, pos=c(5, 10))
Documentation reproduced from package DescTools, version 0.99.19, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.