Skip to content

Instantly share code, notes, and snippets.

@dmarcelinobr
Created December 30, 2015 16:58
Show Gist options
  • Save dmarcelinobr/209697e1f1bfc2f19abc to your computer and use it in GitHub Desktop.
Save dmarcelinobr/209697e1f1bfc2f19abc to your computer and use it in GitHub Desktop.
Test 2: Extend pander to also work with CrossTable R objects
pander.CrossTable <- function(x, ...) {
pandoc.table(x$t, caption = 'Observed Count')
pandoc.table(x$prop.row, caption = 'Row percentages')
pandoc.table(x$prop.col, caption = 'Column percentages')
emphasize.strong.cells (which(x$chisq$residuals > 2,arr.ind=T))
emphasize.strong.cells (which(x$chisq$residuals < -2,arr.ind=T))
pandoc.table(x$chisq$residuals, caption = 'Residuals of the Chi-sqaured test')
paste(c('P-value of the Chi-squared test:',round(x$chisq$p.value,3)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment