[R] NA's introduced by coercion
Steve Lianoglou
lianogls at gene.com
Wed Aug 27 07:21:19 CEST 2014
Hi Madhvi,
First, please use "reply-all" when responding to emails form this list
so that others can help (and benefit from) the discussion.
Comment down below:
On 26 Aug 2014, at 22:15, madhvi.gupta wrote:
> On 08/27/2014 10:42 AM, Steve Lianoglou wrote:
>> Hi,
>>
>> On Tue, Aug 26, 2014 at 9:56 PM, madhvi.gupta
>> <madhvi.gupta at orkash.com> wrote:
>>> 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?
>> 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
>>
>> Hi,
> I am having this error bacouse vector contains value NA but i want to
> convert that vector to numeric
I don't quite follow what the problem is, then ... what is the end
result that you want to happen?
When you convert the vector to a numeric, the NA's that were in it
originally, will remain as NAs (but they will be of a 'numeric' type).
What would you like to do with the NA values? Do you just want to keep
them, but want to silence the warning?
If so, you can do:
R> suppressWarnings(y <- as.numeric(x))
-steve
--
Steve Lianoglou
Computational Biologist
Genentech
More information about the R-help
mailing list