Skip to content

missing values

6 messages · Ivan Calandra, Michael Bedward, Iasonas Lamprianou +1 more

#
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.lamprianou at manchester.ac.uk
#
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 :

  
    
#
And just to add to Ivan's comment, if you are using the rowSums or
colSums functions with a matrix or data.frame they also have the na.rm
argument.

Michael
On 1 December 2010 20:16, Ivan Calandra <ivan.calandra at uni-hamburg.de> wrote:
#
thank you, I'll have a go and let you know if i have problems
 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.lamprianou at manchester.ac.uk



----- Original Message ----
From: Michael Bedward <michael.bedward at gmail.com>
To: ivan.calandra at uni-hamburg.de; lamprianou at yahoo.com; Rhelp 
<r-help at r-project.org>
Sent: Wed, 1 December, 2010 11:40:13
Subject: Re: [R] missing values

And just to add to Ivan's comment, if you are using the rowSums or
colSums functions with a matrix or data.frame they also have the na.rm
argument.

Michael
On 1 December 2010 20:16, Ivan Calandra <ivan.calandra at uni-hamburg.de> wrote:
#
You can also explore the classical() function in the MiscPsycho package that does item analysis.
#
thank you, I'll have a good look and come back to you if necessary
 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.lamprianou at manchester.ac.uk



----- Original Message ----
From: "Doran, Harold" <HDoran at air.org>
To: Iasonas Lamprianou <lamprianou at yahoo.com>; Michael Bedward 
<michael.bedward at gmail.com>; "ivan.calandra at uni-hamburg.de" 
<ivan.calandra at uni-hamburg.de>; Rhelp <r-help at r-project.org>
Sent: Wed, 1 December, 2010 18:39:42
Subject: RE: [R] missing values

You can also explore the classical() function in the MiscPsycho package that 
does item analysis.