Description Usage Arguments Details Value See Also Examples
Only for internal use in pairwiseTest.
1 |
x |
a vector of success and failure in sample x, or a data.frame with a column of successes and a column of failures, then colSums are used. |
y |
a vector of success and failure in sample y, or a data.frame with a column of successes and a column of failures, then colSums are used. |
alternative |
character string defining the alternative hypothesis |
test |
a single character string: which function to be called, choices are "prop.test" for the chi-square test, and "fisher.test" for Fishers exact test, as they are defined in package stats |
... |
arguments to be passed to prop.test(stats) or fisher.test(stats) |
Just a wrapper function to call prop.test(stats). If x, y are data.frames containing two columns taken to be counts of successes and counts of failures, columnwise sums of x,y are calculated. The total number of successes and the total number of trials is then passed to prop.test.
An object of class "htest", as defined by prop.test(stats)
prop.test, and pairwise.prop.test in stats
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # If input is a data.frame:
set.seed(1234)
trials=rep(20,8)
success <- rbinom(n=8, size=trials,
prob=c(0.2,0.2,0.2,0.2, 0.3,0.3,0.3,0.3))
failure <- trials-success
f<-as.factor(rep(c("group1", "group2"), each=4))
data<-data.frame(success=success, failure=failure, f=f)
g1<-subset(data, f=="group1")[,c("success","failure")]
g2<-subset(data, f=="group2")[,c("success","failure")]
g1
g2
# Prop.test calculates the columnwise sums and calls prop.test stats:
Prop.test(x=g1, y=g2)
# should be the same as:
CS1<-colSums(g1)
CS2<-colSums(g2)
CS1
CS2
prop.test(x=c(CS1[1], CS2[1]), n=c(sum(CS1), sum(CS2)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.