str_slice: Slice a Vector at Consecutive Indices

Description Usage Arguments Value Note See Also Examples

View source: R/str_slice.R

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. Not safe for use with unicode characters.

Usage

1
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].

Note

Underlying code is written in C for fast execution.

See Also

str_slice2, for slicing a UTF-8 encoded vector.

Examples

1
2
x <- c("ABCD", "EFGH", "IJKLMN")
str_slice(x, 2)

kevinushey/Kmisc documentation built on May 20, 2019, 9:08 a.m.