Try this:

table(factor(pre, levels = c("D", "F", "T")),
        factor(post, levels = c("D", "F", "T")))

On Mon, Jun 22, 2009 at 8:56 PM, Jeffrey Edgington <jedgingt@du.edu> 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)
>
> 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
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]


