Chciałbym użyć funkcji tabelarycznej() z tabeli-pakietów, aby utworzyć krzyżową tabelę dwóch zmiennych (np. v1 i v2) i przedstawić wartość p testu chisq w tabeli. Łatwo jest uzyskać tabelę, ale nie mogę uzyskać wartości p wewnątrz tabeli. To właśnie próbowałam, bez powodzenia:Statystyka testowa (np. Test chisquare) wewnątrz tabeli lateksowej za pomocą tabeli-pakietu w R/Knitr/Rstudio
\documentclass{article}
\begin{document}
<<echo=TRUE,message=FALSE>>=
library(Hmisc)
library(tables)
v1 <- sample(letters[1:2],200,replace=TRUE)
v2 <- sample(month.name[1:3],200,replace=TRUE)
df <- data.frame(v1,v2)
@
It is straight forward to get the crosstabulation:
<<results='asis'>>=
latex( tabular( Factor(v1) ~ Factor(v2) , data=df) )
@
But I cant get the p-value inside the table:
<<results='asis'>>=
latex( tabular( Factor(v1)*chisq.test(v1,v2)$p.value ~ Factor(v2) , data=df) )
@
\end{document}
Może mógłbyś użyć pakietu [reporttools] (http://cran.r-project.org/web/packages/reporttools/index.html). – sgibb