[R] character position
Dimitris Rizopoulos
d.rizopoulos at erasmusmc.nl
Thu Sep 18 10:59:06 CEST 2008
you could use gsub(), e.g.,
strg <- "There are 20 species in this grid"
gsub("[^0-9]", "", strg)
I hope it helps.
Best,
Dimitris
Paulo Cardoso wrote:
> Hi,
>
> I'm not being able to capture a position of a 'string' in a character
> string.
>
> In this example: 'There are 20 species in this grid'
>
> I would like to capture the string (number) after 'are' and before
> 'species'. Consider they do not change. I wouldn't like to use substr
> because stop position may change.
>
> Thanks
>
> Paulo
>
> ______________________________________________
> 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.
>
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
More information about the R-help
mailing list