Skip to content

NA's introduced by coercion

3 messages · madhvi.gupta, Steve Lianoglou, David Winsemius

#
Hi,

I am applyin function as.numeric to a vector having many values as NA 
and it is giving :
Warning message:
NAs introduced by coercion

Can anyone help me to know how to remove this warning and sor it out?

Thanks
Madhvi
#
Hi,
On Tue, Aug 26, 2014 at 9:56 PM, madhvi.gupta <madhvi.gupta at orkash.com> wrote:
Let's say that the vector you are calling `as.numeric` over is called
`x`. If you could show us the output of the following command:

R> head(x[is.na(as.numeric(x))])

You'll see why you are getting the warning.

How you choose to sort it out probably depends on what you are trying
to do with your data after you convert it to a "numeric"

-steve
#
On Aug 26, 2014, at 9:56 PM, madhvi.gupta wrote:

            
You are the one that needs to identify the cause of hte warning: look at the difference in console output for these two examples:
[1] NA  1 NA
Warning message:
NAs introduced by coercion
[1]  2  1 NA

So it is not the NA's in that character vector but rather values that were coerce to NA because the conversion could not be accomplished.