Below is suggested code for adding a "tail" argument to the "substring" function. Getting the end of a string is a fairly common operation in finance where the exchange of an asset is often encoded. This is a new implementation, but I don't think there are any tricky bits I haven't thought of. function (text, first, last = 1e+06, tail=NULL) { storage.mode(text) <- "character" if(length(tail)) { if(!missing(first)) stop("only one of first and tail allowed") nc <- nchar(text) first <- nc - tail + 1 } n <- max(lt <- length(text), length(first), length(last)) if (lt && lt < n) text <- rep(text, length.out = n) substr(text, first, last) } <environment: namespace:base> As implemented here "tail" gives the distance from the original end of the strings, not the number of characters in the answer (when "last" is given). Patrick Burns Burns Statistics patrick@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User")