shortenStr: Shorten strings to a given number of characters

Description Usage Arguments Value Note Examples

View source: R/string.R

Description

Shorten strings to a given number of characters

Usage

1

Arguments

str

A vector of strings

nchar

The maximal number of characters to keep

Value

A vector of strings of the same length as the input, with each string shortened to the desired length

Strings with more characters than nchar will be shortened.

Note

NA will be kept as they are

Examples

1
2
3
inputStrs <- c("abc", "abcd", "abcde", NA)
shortenStr(inputStrs, nchar=4)
## expected outcome: abc, abcd, abcd..., NA

ribiosUtils documentation built on March 13, 2020, 2:54 a.m.