# [R] Prevalence by site. Stuck after fisher.test and pairwise.t.test

#### Saccharo

##### New Member
Hi,

I run into a problem I can't solve and I got stuck doing the pairwise.t.test. I'll try to give you as many details I could so maybe you can help me out. Thanks in advance.

I'm studying the prevalence of one parasite on a host from different localities. I do it by assigning presence ("1") or absence ("0") to each host sampled.

After the sampling, I got something like this

Code:
site <- c("A", "A", "B", "B", "B", "C", "C","A", "A", "B", "B", "B", "C", "C","A", "A", "B", "B", "B", "C", "C","A", "A", "B", "B", "B", "C", "C")
infection <- c("1", "1", "0", "0", "0", "1", "0","1", "1", "0", "0", "0", "1", "1","1", "1", "0", "0", "1", "1", "1","1", "0", "1", "0", "0", "0", "1")
table1 <- data.frame (site, infection)
Code:
library(dplyr)
table.by.site <- ddply (table1,
"site",
summarise,
Infected = length (which (infection=="1")),
NonInfected = length (which (infection == "0")))
table.by.site
In total, 3 sites and 2 states of infection.

My real numbers:

Length: A= 180; B= 160; C=160

How can I see if the prevalence of the infections depends on the site of sampling?

I have done a fisher.test, finding significant differences:

Code:
table.simple <- table.by.site [,-1] #I remove the "site" column.

fisher.test (table.simple)
But, how I perform a pairwise.t.test? How can I introduce my grouping factor (site)? Should I use a different approach?

Thanks!