pad.left {NCmisc} | R Documentation |
Print a vector with appropriate padding so each has equal char length.
pad.left(X, char = " ", numdigits = NA)
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 |
returns the vector in character format with equal nchar()
Nicholas Cooper njcooper@gmx.co.uk
pad.left(1:10)
phone.numbers <- c("07429719234","7876345123","7123543765")
pad.left(phone.numbers,"0")
pad.left(rnorm(10),numdigits=3)