Learn R Programming

NCmisc (version 1.2.0)

pad.left: Print a vector with appropriate padding so each has equal char length.

Description

Print a vector with appropriate padding so each has equal char length.

Usage

pad.left(X, char = " ", numdigits = NA)

Value

returns the vector in character format with equal nchar()

Arguments

X

vector of data to pad to equal length

char

character to pad with, space is default, but zero might be a desirable choice for padding numbers

numdigits

if using numeric data, the number of digits to keep

Author

Nicholas Cooper njcooper@gmx.co.uk

Examples

Run this code
pad.left(1:10)
phone.numbers <- c("07429719234","7876345123","7123543765")
pad.left(phone.numbers,"0")
pad.left(rnorm(10),numdigits=3)

Run the code above in your browser using DataLab