You need McNemar's test (http://en.wikipedia.org/wiki/McNemar%27s_test , http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3346204/). Following is an example:
1300 pts and 1300 matched controls are studied. The smoking status is tabled as follows:
Normal
|no |yes|
Cancer|No |1000|40 |
|Yes |200 |60 |
Each entry of the table shows information about a CASE-CONTROL PAIR: 1000 means in 1000 case-control pairs, neither was a smoker. 40 is the number of case-control pairs where control was smoker and cancer patient was not, and so on. Following R code can be used to generate this table and do McNemar's Test.
mat = as.table(rbind(c(1000, 40), c( 200, 60) ))
colnames(mat) <- rownames(mat) <- c("Nonsmoker", "Smoker")
names(dimnames(mat)) = c("Cancer", "Normal")
mat
# Normal
# Nonsmoker Smoker
# Cancer
# Nonsmoker 1000 40
# Smoker 200 60
mcnemar.test(mat)
# McNemar's Chi-squared test with continuity correction
#
#data: mat
#McNemar's chi-squared = 105.34, df = 1, p-value < 2.2e-16
McNemar's test is also used to assess effect of an intervention on a binary outcome variable. The pair of before-after outcome is tabled and tested as above.
Edit:
Extending example given by @gung , if smoking status is listed in your dataframe mydf as follows:
pairID cancer control
1 1 1
2 1 1
3 1 0
...
McNemars test can be done with following R commands:
> tt = with(mydf, table(cancer, control))
> tt
control
cancer 0 1
0 5 1
1 3 2
> mcnemar.test(tt)
McNemar`s Chi-squared test with continuity correction
data: tt
McNemar`s chi-squared = 0.25, df = 1, p-value = 0.6171