HI,
sum(var1,var2,var3,var4,var5,na.rm=TRUE)
#[1] 8
A.K.
- Original Message -
From: Jin Choi
To: "r-help@r-project.org"
Cc:
Sent: Saturday, July 20, 2013 12:37 AM
Subject: [R] Adding across columns ignoring NA
I am having difficulty finding a solution to devising an R
Berend:
No. The OP's "variables" appear to be vectors. sum() sums columnwise
(vectorwise).
Something like
rowSums(cbind(var1,var2,var3,var4,var6), na.rm=TRUE)
appears to be what is wanted. But of course,Jin Choi appears to need
to do some homework -- e.g. by reading the Introduction to R online
On 20-07-2013, at 06:37, Jin Choi wrote:
> I am having difficulty finding a solution to devising an R code to do the
> following:
>
> I have 5 numerical variables and I would like to create a new variable that
> is the sum of those 5 variables. However, there are many NA values
> throughout the
I am having difficulty finding a solution to devising an R code to do the
following:
I have 5 numerical variables and I would like to create a new variable that
is the sum of those 5 variables. However, there are many NA values
throughout these 5 variables and everytime I run the following code
n
4 matches
Mail list logo