Learn R Programming

ribiosUtils (version 1.7.7)

fixWidthStr: Shorten strings to strings with a fix width of characters

Description

Shorten strings to strings with a fix width of characters

Usage

fixWidthStr(str, nchar = 8, align = c("left", "right"))

Value

A vector of strings with fixed widths

Arguments

str

A vector of strings

nchar

The fixed with

align

Character, how to align Strings with more or fewer characters than nchar are either shortened or filled (with spaces)

See Also

shortenStr

Examples

Run this code

inputStrs <- c("abc", "abcd", "abcde", "abcdefg", "NA", NA) 
outputStrs <- fixWidthStr(inputStrs, nchar=4)
stopifnot(all(nchar(outputStrs)==4))

Run the code above in your browser using DataLab