[R] Automatically Adding Categories
David Winsemius
dwinsemius at comcast.net
Tue Jun 23 02:29:19 CEST 2009
On Jun 22, 2009, at 7:56 PM, Jeffrey Edgington wrote:
> 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)
>
> The problem is that for several of the questions not all of the
> possible responses appear. So I get
> a table like this:
>
Missing cells added:
T D F
D 6 0 0
F 2 0 0
T 12 0 0
>
> 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?
You might want to exercise appropriate care regarding the validity
concerns, since you obviously have quite a few zero entries.
--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list