make.fixedwidth: Convert Character Vectors From Variable To Constant Width

Description Usage Arguments Details Value Note Author(s) Examples

View source: R/types.R

Description

Utility function to convert a vector of character strings to one where each element has exactly ‘width’-bytes.

Usage

1
make.fixedwidth(x, width = NA, justify = c("left", "right"))

Arguments

x

A character vector.

width

Maximum width of each element. width=NA (default) will expand each element to the width required to contain the largest element of x without loss of information.

justify

How should the results be padded? ‘left’ will add spacing to the right of shorter elements in the vector (left-justified), ‘right’ will do the opposite.

Details

The current implementation of mmap only handles fixed-width strings (nul-terminated). To simplify conversion of (potentially) variable-width strings in a character vector, all elements will be padded to the length of the longest string in the vector or set to length width if specified.

All new elements will be left or right justified based on the justify argument.

Value

A character vector where each element is of fixed-width.

Note

Future implementions will possibly support variable-width character vectors.

Author(s)

Jeffrey A. Ryan

Examples

1
2

mmap documentation built on May 2, 2019, 4:45 p.m.