You are on page 1of 2

## Get in the data ##

unpaired <- read.csv("unpaired_diseased.csv")


unpaired
test result count
1 0 0 82
2 0 1 18
3 1 0 140
4 1 1 60

## Define the crosstab ##

## Define the counts ##


unpaired_diseased <- tapply(unpaired$count,list(unpaired$test,unpaired$result),c)

## Define labels ##
dimnames(unpaired_diseased) <- list(c("Test 1","Test 2"),c("Result
positive","Result negative"))
unpaired_diseased

Result positive Result negative


Test 1 82 18
Test 2 140 60

## Calculate sensitivities for the two tests ##


library(gmodels)
unpaired_diseased_prop <- CrossTable(unpaired_diseased)

## Display the calculated sensitivities ##


unpaired_diseased_prop$prop.row

Result positive Result negative


Test 1 0.82 0.18
Test 2 0.70 0.30

## Load library for Chi-squared test / Fisher's exact test ##


library(exact2x2)

## Chi-squared Test / Fisher's Exact Test ##


fisher.test(unpaired_diseased)

Fisher's Exact Test for Count Data

data: unpaired_diseased
p-value = 0.02617
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
1.048452 3.757027
sample estimates:
odds ratio
1.948250

You might also like