Learn R Programming

dataRetrieval (version 1.4.0)

padVariable: Pad string with leading zeros

Description

Function to pad a string with leading zeros. Useful for parameter codes and USGS site IDs.

Usage

padVariable(x, padTo)

Arguments

x

string

padTo

number Final desired length of the string

Value

x string returned with leading zeros

Examples

Run this code
# NOT RUN {
pCode <- '10'
correctPCode <- padVariable(pCode,5)
pCodes <- c('100','1000','0','12345','1565465465465465')
correctPCodes <- padVariable(pCodes,5)
# }

Run the code above in your browser using DataLab