Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to do the p-value to print only 4 digits instead of the scientific notation in R?
- >options(digits=3, scipen=12)
- >Oi <- c(A=321, B=712, C=44)
- >Ei <- c(A=203, B=28, C=6)
- >chisq.test(Oi, p=Ei,rescale.p=T)"
- cc <- chisq.test(Oi,p=Ei,rescale.p=TRUE)
- print(cc)
- Chi-squared test for given probabilities
- data: Oi
- X-squared = 3090, df = 2, p-value < 0.00000000000000022
- List of 9
- $ statistic: Named num 3090
- ..- attr(*, "names")= chr "X-squared"
- $ parameter: Named num 2
- ..- attr(*, "names")= chr "df"
- $ p.value : num 0
- $ method : chr "Chi-squared test for given probabilities"
- $ data.name: chr "Oi"
- $ observed : Named num [1:3] 321 712 44
- ..- attr(*, "names")= chr [1:3] "A" "B" "C"
- $ expected : Named num [1:3] 922.5 127.2 27.3
- ..- attr(*, "names")= chr [1:3] "A" "B" "C"
- $ residuals: Named num [1:3] -19.8 51.8 3.2
- ..- attr(*, "names")= chr [1:3] "A" "B" "C"
- $ stdres : Named num [1:3] -52.29 55.2 3.25
- ..- attr(*, "names")= chr [1:3] "A" "B" "C"
- - attr(*, "class")= chr "htest"
- (pval <- pchisq(3090,2,lower.tail=FALSE,log.p=TRUE))
- [1] -1545
- Oi <- c(A=321, B=712, C=44)
- Ei <- c(A=203, B=28, C=6)
- tt <- chisq.test(Oi, p=Ei,rescale.p=T)
- format.pval(tt$p.value, eps=0.0001)
- # [1] "<0.0001"
- ttp <- data.frame(Chisq=tt$statistic, p.value=tt$p.value)
- rownames(ttp) <- "Oi vs Ei"
- printCoefmat(ttp, has.Pvalue=TRUE, eps.Pvalue=0.0001)
- # Chisq p.value
- # Oi vs Ei 3090 <0.0001 ***
- # ---
- # Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Add Comment
Please, Sign In to add comment