remove_last_n: Remove Last N Characters

Description Usage Arguments Value Examples

View source: R/miscutils.R

Description

utility function to remove n characters from the end of a character string or strings. Extends functional tools available in stringr package for this common operation. Also allows for a set of characters (missing=” by default) to be specified to show that the string was over-truncated.

Usage

1
remove_last_n(str, n = 0, missing = "")

Arguments

str

the string or vector of strings to be truncated

n

the number of characters at the end to remove

missing

optional sequence to use if an entry is truncated away (default = ”)

Value

the string or strings, reduced by n characters

Examples

1
2
remove_last_n('a sequence #', 2)
remove_last_n(c('a couple+','of sequences+'), 1, '...')

duncankmckinnon/OKdplyr documentation built on Nov. 30, 2020, 1:13 a.m.