Displaying 1 result from an estimated 1 matches for "pn_in".
Did you mean:
pa_in
2009 Mar 18
2
Profiling question: string formatting extremely slow
...ins digits only (can be converted to an integer)
digits_only <- function(x) { suppressWarnings(!is.na(as.integer(x))) }
# Remove blanks at both ends of a string
trim <- function (x) {
sub("^\\s+((.*\\S)\\s+)?$", "\\2", x)
}
# P/N formatting
pn_formatting <- function(pn_in) {
pn_out = trim(pn_in)
if (digits_only(pn_out)) {
# Zero padding
pn_out <- paste("000000000000000000", pn_out, sep="")
pn_len <- nchar(pn_out)
pn_out <- substr(pn_out, pn_len - 17, pn_len)
} else {
# Uppercase
pn_out <- toupper(pn_ou...