Hi,

(a) sum() and mean() have a na.rm argument that should be set to TRUE.

(b) let's try with an example:
x <- c(1:5, NA, NA, 6:10, NA)
x[is.na(x)] <- 0  ## replace NAs by 0

HTH,
Ivan


Le 12/1/2010 10:00, Iasonas Lamprianou a écrit :
Dear all,
i have spent a lot of time trying to solve this problem, but I am sure that
there must be a simple solution. So, as a last resort, I am coming back to you
again. I have a dataset with some (almost random) values in many variables. Lets
say that the dataset represents the scores of students to test questions. What I
need to do is to sum the scores for each student. However, wherever there is a
missing (NA) value, I cannot get the total score.  How can I compute the total
score and the average per question (a) by ignoring the missing responses, (b) by
assuming that a missing response is a zero?
Thank you for the response


  Dr. Iasonas Lamprianou




Assistant Professor (Educational Research and Evaluation)
Department of Education Sciences
European University-Cyprus
P.O. Box 22006
1516 Nicosia
Cyprus
Tel.: +357-22-713178
Fax: +357-22-590539




Honorary Research Fellow
Department of Education
The University of Manchester
Oxford Road, Manchester M13 9PL, UK
Tel. 0044  161 275 3485
iasonas.lampria...@manchester.ac.uk





______________________________________________
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.


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php

______________________________________________
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.

Reply via email to