[R] misbehavior with extract_numeric() from tidyr
h.wickham at gmail.com
Mon Apr 20 21:10:44 CEST 2015
On Mon, Apr 20, 2015 at 1:57 PM, arnaud gaboury
<arnaud.gaboury at gmail.com> wrote:
> On Mon, Apr 20, 2015 at 6:09 PM, William Dunlap <wdunlap at tibco.com> wrote:
>> The hyphen without a following digit confuses tidyr::extract_numeric().
>> > extract_numeric("23 ft-lbs")
>> Warning message:
>> In extract_numeric("23 ft-lbs") : NAs introduced by coercion
>>  NA
>> > extract_numeric("23 ft*lbs")
>>  23
> See for the reason on the minus in the regex. It is not a bug but a wish.
> I am honestly very surprised the maintainer decided to go with such a so
> simple solution for negative numbers.
Any heuristic is going to fail in some circumstances. If you want to
be sure it's doing what you want for your use case, write the regular
More information about the R-help