Try this where [0-9]+ matches one or more digits and $ matches the end of string. See http://gsubfn.googlecode.com for more.
library(gsubfn) x <- c("v2FfaPre15", "v2FfaPre10", "v2FfaPre5", "v2Ffa2", "v2Ffa3", "v2Ffa4") strapply(x, "[0-9]+$", c, simplify = TRUE) # or if you want a numeric result: strapply(x, "[0-9]+$", as.numeric, simplify = TRUE) On Thu, Dec 3, 2009 at 9:00 AM, oscar linares <wins...@gmail.com> wrote: > Dear Wiza[R]ds, > > I have a data.frame header that looks like this: > > v2FfaPre15 v2FfaPre10 v2FfaPre5 v2Ffa2 v2Ffa3 v2Ffa4 > > I need it to look like this, > > 15 10 5 2 3 4 > > i.e., with v2FfaPre and v2Ffa stripped off > > Any suggestions, > > Thanks in advance! > > -- > Oscar > Oscar A. Linares, MD > Translational Medicine Unit > LaPlaisance Bay, Bolles Harbor > Monroe, Michigan 48161 > > Department of Medicine, > University of Toledo College of Medicine > Toledo, OH 43606-3390 > > Department of Internal Medicine, > The Detroit Medical Center (DMC) > Harper University Hospital > Wayne State University School of Medicine > Detroit, Michigan 48201 > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > [[alternative HTML version deleted]] ______________________________________________ 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.