condense_str: Condense String

Description Usage Arguments Details Value Examples

View source: R/condense_str.R

Description

condense_str shortens a string to a specified length. View details for explanation.

Usage

1
2
condense_str(x, cutoff = 30, strict = FALSE, rm.spaces = FALSE,
  rm.words = NULL)

Arguments

x

A string.

cutoff

Cutoff index.

strict

Return string with nchar less than or equal to cutoff index?

rm.spaces

Remove all spaces in string after condensing?

rm.words

A vector of characters or words to be removed from x. All instances removed. Case sensitive.

Details

condense_str will not cut off a string midword. If your string's nth character (where n = cutoff) lies in the middle of a word, condense_str looks for the end of that word then cuts off the string there. If strict is set to TRUE, condense_str will always return a string where the number of characters is less than or equal to cutoff.

Value

A condensed version of x.

Examples

1
2
3
4
condense_str("This is a test string", cutoff = 13)
condense_str("This is a test string", cutoff = 13, strict = T, rm.spaces = T)

condense_str("This is a test string", cutoff = 13, strict = T, rm.words = c("This","test"))

faouser1/FAO documentation built on Nov. 4, 2019, 12:35 p.m.