Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

make.fixedwidth

Convert Character Vectors From Variable To Constant Width


Description

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

Usage

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

month.name
make.fixedwidth(month.name)

mmap

Map Pages of Memory

v0.6-19
GPL-3
Authors
Jeffrey A. Ryan
Initial release
2020-01-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.