Open discoleo opened 1 year ago
The seq.character function is now overloaded:
seq.character = function(from, to) {
if(nchar(from[1]) > 1) {
# convenience functionality;
if(is.numeric(to)) return(seq.nchar(from, to));
}
from = as.integer(charToRaw(from));
isUpper = if(from <= 90) TRUE else FALSE;
off = if(isUpper) 64 else 96;
from = from - off;
# Length:
if(is.numeric(to)) {
if(isUpper) return(LETTERS[seq(from, from + to - 1)]);
return(letters[seq(from, from + to)]);
}
to = as.integer(charToRaw(to)) - off;
if(isUpper) return(LETTERS[seq(from, to)]);
return(letters[seq(from, to)]);
}
# simple replacement for paste(from, seq(n), sep="")
seq.nchar = function(from, length.out, start.at=1, sep="") {
paste(from, seq(start.at, length.out=length.out), sep=sep)
}
# A:H seq("A", "H") # A, length = 8 seq("A", 8) # c("Str1", ..."Str6") seq("Str", 6)
New Utility Function: seq.character
The generation of sequences of letters is currently hard-coded in many of the functions. However, it may be useful to be able to generate sequences of letters on the fly. A function seq.character may be useful in such situations.
R Code
Usage
Note: