# it's not clear what your question is, but here's a stab in the dark at a
solution!
ind<- !is.na(dataframe$A) & !is.na(dataframe$B)
dataframe$A[ind] + dataframe$B[ind]
- Dan
P.S. I'm sure there are ways to do this using one of R's functions for
automatically removing NA's (na.rm = T), but unle
taframe$A )
-Original Message-
From: "Sarah Goslee" [sarah.gos...@gmail.com]
Date: 09/06/2015 07:00 PM
CC: "r-help"
Subject: Re: [R] Handling "NA" in summation
I'm not quite sure how you get zero from that situation. Do you expect
the answer to be 20?
H
>dataframe[ is.na(dataframe) ] <- 0
>dataframe[ is.nan(dataframe) ] <- 0
>dataframe[ is.infinite(dataframe) ] <- 0
>
>-Original Message-
>From: "Olu Ola via R-help" [r-help@r-project.org]
>Date: 09/06/2015 06:24 PM
>To: r-help@r-project.org
>Su
> Date: 09/06/2015 06:24 PM
> To: r-help@r-project.org
> Subject: [R] Handling "NA" in summation
>
> Hello,
> I am currently working with a dataframe which has some missing values
> represented by "NA". whenever, I add two columns in which at least one of the
&
That is not how R works. 20+NA is NA, which is not the same as zero. This is
not optional behaviour.
I notice that you put quotes around the NA if those really are there then
you should be getting an error.
You need to assemble a reproducible example, such as is described at [1]. By
doing
I use something like :
dataframe[ is.na(dataframe) ] <- 0
dataframe[ is.nan(dataframe) ] <- 0
dataframe[ is.infinite(dataframe) ] <- 0
-Original Message-
From: "Olu Ola via R-help" [r-help@r-project.org]
Date: 09/06/2015 06:24 PM
To: r-help@r-project.org
Subjec
Hello,
I am currently working with a dataframe which has some missing values
represented by "NA". whenever, I add two columns in which at least one of the
pair of an observation is "NA", the sum returns zero. That is for the same
observation, if
dataframe$A = 20
dataframe$B = NA
dataframe$A +
7 matches
Mail list logo