Try this: gsub(".*\\((\\d+)\\).*", "\\1", aaa)
On Tue, Feb 1, 2011 at 3:42 PM, Yan Jiao <y.j...@ucl.ac.uk> wrote: > Dear R guru: > > > > If I got a variable > > aaa<- "up.6.11(16)" > > > > how can I extract 16 out of the bracket? > > I could use substr, e.g. > > substr(aaa, start=1, stop=2) > > [1] "up" > > > > But it needs start and stop, what if my start or stop is not fixed, I > just want the number inside the bracket, how can I achieve this? > > > > Many thanks > > > > yan > > > ********************************************************************** > This email and any files transmitted with it are confide...{{dropped:10}} > > ______________________________________________ > 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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[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.