[R] data manipulation

jim holtman jholtman at gmail.com
Thu Dec 3 15:05:14 CET 2009


try this:

> x <- c('v2FfaPre15',    'v2FfaPre10',    'v2FfaPre5',    'v2Ffa2',    'v2Ffa3',    'v2Ffa4')
> sub("^.*?([0-9]+)$", "\\1", x, perl=TRUE)
[1] "15" "10" "5"  "2"  "3"  "4"
>


On Thu, Dec 3, 2009 at 9:00 AM, oscar linares <winsaam at 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 at 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list