Learn R Programming

BioGeoBEARS (version 0.2.1)

extract_numbers: Extract just the numbers from a string, including decimal points

Description

This function extracts numbers from a string. Contiguous digits, including decimal points, are made into a single number. A list of numbers is returned.

Usage

extract_numbers(tmpstr)

Arguments

tmpstr
An input string.

Value

x2 The list of numbers

Details

This saves you having to remember the regexp/gregexpr code for this sort of thing, and makes it much easier to parse numbers out of the text output of various programs.

References

http://phylo.wikidot.com/matzke-2013-international-biogeography-society-poster

Matzke_2012_IBS

See Also

gregexpr

Examples

Run this code
tmpstr = "190Ma - 65Ma"
extract_numbers(tmpstr)

tmpstr = "190.1Ma - 65.5Ma"
extract_numbers(tmpstr)

Run the code above in your browser using DataLab