-1

This is the code I am using, which runs fine in Rstudio

a1 <- matrix(c(1601, 162527, 510, 412368), nrow=2, byrow=T)  
chisq.test(a1, correct=F)

This is the error I get

! Undefined control sequence.  
<argument> ^^M##^^M##  Pearson'  
s Chi-squared test^^M##^^M## data:  a1^^M## X...  
l.356 \end{verbatim}  

The control sequence at the end of the top line  
of your error message was never \def'ed. If you have  
misspelled it (e.g., `\hobx'), type `I' and the correct  
spelling (e.g., `I\hbox'). Otherwise just continue,  
and I'll forget about whatever was undefined.

It would work if I do

c1 <- chisq.test(a1, correct=F)

then call for the p-value using

c1$p.value

What is causing this problem?

N8TRO
  • 3,348
  • 3
  • 22
  • 40
Saber CN
  • 765
  • 1
  • 6
  • 7

1 Answers1

2

This is a known bug which has been fixed in the development version (see NEWS). For now, you can install it from:

install.packages('knitr', repos = 'http://www.rforge.net/')
Yihui Xie
  • 28,913
  • 23
  • 193
  • 419