## Dung observations
## Create a sample original data
data <- data.frame(Species=sample(c("W", "G", "R"), 200, replace=TRUE),
        Age=sample(c("days", "weeks", "months"),200,replace=TRUE),
        Termites=sample(c(0,1),200,replace=TRUE))

## Show what original data look like
head(data)

  Species    Age Termites
1       W months        0
2       R  weeks        0
3       W  weeks        0
4       G  weeks        0
5       R months        1
6       W   days        1


## Analyze each species 
## Here we just tabulate Waterbuck as an example
data.w <- data[data$Species == "W",]
table.w <- table(data.w[,2:3])

## The results table looks like
table.w
        Termites
Age       0  1
  days   18  9
  months  9 11
  weeks  10 18
  
## Apply Chi-squared Test
chisq.test(table.w)

## Usually use Pearson's Chi-squared Test
## If your data are not suitable for the Pearson's Chi-squared Test, it
seems that R will tell you. 
## H0 : All three age groups have same Termites attack percentage.
## H1 : All situations except H0.

-----
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Comparing-three-groups-data-present-absent-tp2224751p2225612.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to