Re: [R] getting last 2 charcters of a string, other "text" functions?

From: Chuck Cleland <ccleland_at_optonline.net>
Date: Tue 01 Nov 2005 - 02:48:00 EST

?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@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

______________________________________________
R-help@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
Received on Tue Nov 01 03:15:43 2005

This archive was generated by hypermail 2.1.8 : Tue 01 Nov 2005 - 09:45:04 EST