On Tue, Jul 13, 2010 at 3:20 AM, Lorenzo Cattarino <l.cattar...@uq.edu.au> wrote: > Hello R-users, > > > > I have a very large vector (a) containing elements consisting of numbers > and letters, this is the i.e. > > a > > [1] "1.11.2a" "1.11.2d" "1.11.2e" "1.11.2f" "1.11.2x1" > "1.11.2x1b" > [...] > > How can I remove from each record everything that is after the number > after the second dot? E.g.: > > 1.11.2a becomes 1.11.2, 1.12.1x4 becomes 1.12.1, 1.9.1a becomes > 1.9.1...and so forth.
If they are all of the form shown then the question is equivalent to removing the first alphabetic character, [[:alpha:]], and everything thereafter (.*) which is just this. sub("[[:alpha:]].*", "", a) ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.