Last active
August 29, 2015 13:57
-
-
Save jmcastagnetto/9769367 to your computer and use it in GitHub Desktop.
Code that illustrates the sj.xtab() bug when rendering to HTML with knitr (ref: https://github.com/sjPlot/devel/issues/1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bug in sjt.xtab() | |
```{r} | |
require(sjPlot) | |
set.seed(12345) | |
var1 <- as.factor(sample(c("ok", "not ok"), 1000, replace=TRUE, prob=c(0.2, 0.8))) | |
var2 <- as.factor(sample(c("foo", "bar", "boing", "kaboom", "plonk"), 1000, replace=TRUE)) | |
var3 <- sample(2:20, 1000, replace=TRUE) | |
xtab1 <- sjt.xtab(var2, var3, var1, variableLabels=c("var2", "var3", "var1"), | |
showSummary=FALSE, showLegend=FALSE, no.output=TRUE) | |
``` | |
## Table made using sjt.xtab() | |
`r xtab1$knitr` | |
## Output of xtabs() | |
```{r} | |
xtabs( ~ var2 + var3 + var1) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This bug has been fixed by the sjPlot author in version 1.3