On Mon, Apr 20, 2015 at 1:57 PM, arnaud gaboury <arnaud.gabo...@gmail.com> wrote: > On Mon, Apr 20, 2015 at 6:09 PM, William Dunlap <wdun...@tibco.com> wrote: > >> The hyphen without a following digit confuses tidyr::extract_numeric(). >> E.g., >> > extract_numeric("23 ft-lbs") >> Warning message: >> In extract_numeric("23 ft-lbs") : NAs introduced by coercion >> [1] NA >> > extract_numeric("23 ft*lbs") >> [1] 23 >> > > See[0] 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. > > [0]https://github.com/hadley/tidyr/issues/20
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 expression yourself. Hadley -- http://had.co.nz/ ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.