[R] Create 2x2 table from summary data and run chi square test.

From: John Sorkin <JSorkin_at_grecc.umaryland.edu>
Date: Fri, 22 Apr 2011 14:37:57 -0400

R 2.12
windows 7

I am summary data that I would like to make into a 2x2 table representing counts positive vs. negative counts: 28/289 20/276

My table should look something like the following:

          group1 group2
Positive    28     20
Negative   289     276

How can a (1) create the 2x2 table
          (2) run a chi square test on the table?

I have tried the following code, but I don't know if it is correct, and it does not give me an explicit 2x2 table:

> xx <- c(28,20)
> pp <- c(317/(317+296), 296/(317+296))
> chisq.test(xx,p=pp)

        Chi-squared test for given probabilities

data: xx
X-squared = 0.8425, df = 1, p-value = 0.3587

John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center
10 North Greene Street
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

R-help_at_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. Received on Fri 22 Apr 2011 - 18:41:01 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 22 Apr 2011 - 19:40:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive