[R] getting last 2 charcters of a string, other "text" functions?
Chuck Cleland
ccleland at optonline.net
Mon Oct 31 16:48:00 CET 2005
?nchar
?substr
rightmost <- function(x, y){substr(x, start=nchar(x) - (y - 1),
stop=nchar(x))}
> x <- c("asfef", "qwerty", "yuiop[", "b", "stuff.blah.yech")
> rightmost(x, 2)
[1] "ef" "ty" "p[" "b" "ch"
> rightmost(x, 3)
[1] "fef" "rty" "op[" "b" "ech"
t c wrote:
> I wish to obtain the right-most n characters of a character string? What is the appropriate function?
>
>
>
> ---------------------------------
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894
More information about the R-help
mailing list