On Jan 10, 2012, at 11:25 AM, Petra Opic wrote:
Dear everyone,
I have looked all over the internet but I cannot find a way to solve
my problem.
? rowSums # has an na.rm argument
In my data I want to sum a couple of variables. Some of these
variables have NA values, and when I add them together, the result is
NA
snip
attach(dat)
You would be well-advised to forget `attach`. Use with(dat, ...)
instead. It will prevent frustration and embarrassing postings to rhelp.
dat$sum <- var2 + var3 + var4
The plus infix operator does not have an na.rm argment
dat$sum <- rowSums(dat[ , 2:4] , na.rm=TRUE)
--
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.