Re: [R] Using grep to determine value of last letter...

2009-10-19 Thread Gabor Grothendieck
Here are several ways to find the last character in a string: > x <- "abc" > substring(x, nchar(x)) [1] "c" > sub(".*(.)", "\\1", x) [1] "c" > library(gsubfn) > strapply(x, ".$")[[1]] [1] "c" On Mon, Oct 19, 2009 at 3:52 PM, Jason Rupert wrote: > I am currently being defeated by grep.  I am a

Re: [R] Using grep to determine value of last letter...

2009-10-19 Thread Bert Gunter
stLetter <- substr(yourstring, n, n) Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jason Rupert Sent: Monday, October 19, 2009 12:52 PM To: R-help@r-project.org Subject: [R] Us

[R] Using grep to determine value of last letter...

2009-10-19 Thread Jason Rupert
I am currently being defeated by grep. I am attempting to determine the value of the last letter of a character string. An example of my data set is shown below. Regarding the codes, I would like to identify the value of the last character and then take the appropriate action, e.g. If the