[R] Automatically Adding Categories
Jeffrey Edgington
jedgingt at du.edu
Tue Jun 23 01:56:27 CEST 2009
Greetings,
I have two files which contain responses to a series of multiple
choice questions. One
file contains responses before an "intervention" and the other
contains the responses afterward.
There were three possible responses to each question: D, F, T (for
Don't Know, False, and True).
I would like to try McNemar's test to determine if there was any
significant difference between before
and after.
I read the files. I create tables using:
firstQuestion <- table( PreSurveyData$q1, PostSurveyData$q2)
for example.
The problem is that for several of the questions not all of the
possible responses appear. So I get
a table like this:
T
D 6
F 2
T 12
Which cannot be used in mcnemar.test because it is not a square table
and does not have enough rows and columns.
Is there some way to specify that R should count the occurrences of
D, F, and T even though they do not appear
in the Data? Or some easy way to add the missing columns?
Thank you,
Jeffrey Edgington
More information about the R-help
mailing list