Re: [R] Convert a character to numeric

2019-04-09 Thread Boris Steipe
As there are many possible sources of the warning, to "sort it out" try something like which( is.na() & (! is.na())) B. > On 2019-04-09, at 11:02, Richard M. Heiberger wrote: > > My guess is that numbers formatted with commas are causing an unwanted > coercion. > Remove the commas with

Re: [R] Convert a character to numeric

2019-04-09 Thread Richard M. Heiberger
My guess is that numbers formatted with commas are causing an unwanted coercion. Remove the commas with gsub before converting to numeric. > as.numeric(NA) [1] NA > as.numeric("1,234,567") [1] NA Warning message: NAs introduced by coercion > as.numeric(gsub(",", "", "1,234,567")) [1] 1234567 > On

Re: [R] Convert a character to numeric

2019-04-09 Thread Alfredo Cortell
Hi Bienvenue, I believe that your problem is that R can't translate "one" to a number, because it is not a number. R could translate to numeric for example this vector, where numbers are expressed as strings, c("1","4","7") but "one" is just letters put together, therefore R can't understand the

Re: [R] Convert a character to numeric

2019-04-09 Thread Duncan Murdoch
On 09/04/2019 7:30 a.m., Jim Lemon wrote: Hi Bienvenue, Perhaps you should ask whether you really want to "sort it out". The warning is telling you that you are converting the NA values to NA in the returned numeric vector. I don't think that's what it is saying. I think it is saying that a n

Re: [R] Convert a character to numeric

2019-04-09 Thread Jim Lemon
Hi Bienvenue, Perhaps you should ask whether you really want to "sort it out". The warning is telling you that you are converting the NA values to NA in the returned numeric vector. I can't think of anything more sensible to do with NA values. You may also have character strings that cannot be conv