Learn R Programming

Kmisc (version 0.2.0)

str_slice: Slice a Vector at Consecutive Indices

Description

This function 'slices' the strings of a character vector x at consecutive indices n, thereby generating consecutive substrings of length n and returning the result as a list.

Usage

str_slice(x, n = 1)

Arguments

x
a character vector.
n
integer (or numeric coercible to integer); index at which to slice.

Value

  • A list of length equal to the length of x, with each element made up of the substrings generated from x[i].