Skip to content
Prev 68935 / 398513 Next

"apply" question

you could try something like this:

dat <- rbind(c(1, 2, 5, 2, 3, NA, 5, NA, 1, 4),
             c(3, 1, 4, 5, 2, 6, NA, 4, NA, 1))
##########
# (1)
rowSums(is.na(dat[, 6:10]))

## (2)
dat. <- dat[, 1:5]
dat.[is.na(dat[, 6:10])] <- NA
rowSums(dat., na.rm=TRUE)
rowMeans(dat., na.rm=TRUE)


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Christoph Scherber" <Christoph.Scherber at uni-jena.de>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, May 02, 2005 4:52 PM
Subject: [R] "apply" question