Skip to content
Prev 350173 / 398506 Next

misbehavior with extract_numeric() from tidyr

On Mon, Apr 20, 2015 at 12:09 PM, Jim Lemon <drjimlemon at gmail.com> wrote:
I was thinking of 'x' as being the culprit (interpreted as multiply)
but you are right indeed

noHyphens <- str_replace(playerStats[c(22,24)],'-','')
 extract_numeric(noHyphens)
[1]   276 83226


in fact:
---------------------------------------------------------
 extract_numeric
function (x)
{
    as.numeric(gsub("[^0-9.-]+", "", as.character(x)))
}
<environment: namespace:tidyr>
---------------------------------------------------------

Is there any particular reason for the hyphen in gsub() ? Why not
remove it thus ?

TY much Jim