Closed jmgirard closed 4 years ago
Does this help as workaround? (see last post) https://github.com/r-lib/crayon/issues/24
maybe there is a way to wrap the print() method of tidy_stan() in a knitr-command, like knitr_print.tidy_stan()
, and then skip the colored output.
(reminder: see tibble:::knit_print.trunc_mat()
)
Unfortunately, the two workarounds did not work for me.
Actually, I can't reproduce your issue. Are all your packages (related to knitr, tibble, ...) up to date?
But anyway, I tried something that might fix your issue, could you install from GitHub and check?
When using print(tidy_stan(fit))
I get the same issue with the dev version of sjstats.
Everything seems to be up to date:
This seems to be getting closer. No color but also an error message:
library(sjstats)
library(brms)
fit <- brm(
formula = count ~ zAge + zBase * Trt + (1 | patient),
data = epilepsy,
family = poisson(),
prior = c(
prior(student_t(5, 0, 10), class = b),
prior(cauchy(0, 2), class = sd)
),
refresh = 0,
file = "test"
)
sjstats:::knit_print.tidy_stan(tidy_stan(fit))
# Summary Statistics of Stan-Model
Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
Consider 'structure(list(), *)' instead.Error in enc2utf8(x) : argument is not a character vector
You should run the inital code, just tidy_stan()
.
No change - it doesn't seem to find the knit_print function properly and is still blue in console and unescaped in HTML.
The preview doesn't seem to work, I guess, but what if you knit the HTML file?
The HTML file when using output: html_notebook
is still wrong.
However, if I change to output: html_document
I get the following:
##
## # Summary Statistics of Stan-Model
##
## estimate std.error ci.lvl HDI(89%) ratio rhat mcse
## Intercept 1.77 0.12 89 [ 1.58 1.96] 0.16 1.00 0.00
## zAge 0.09 0.09 89 [-0.04 0.23] 0.16 1.00 0.00
## zBase 0.71 0.12 89 [ 0.52 0.89] 0.18 1.01 0.00
## Trt1 -0.27 0.16 89 [-0.52 0.01] 0.17 1.00 0.01
## zBase.Trt1 0.06 0.16 89 [-0.20 0.30] 0.19 1.00 0.01
## Warning in structure(x, class = "knit_asis", knit_meta = meta, knit_cacheable = cacheable): Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
## Consider 'structure(list(), *)' instead.
So this looks good (excepting the warning).
strange, I just copied your initial code and got this:
I am getting this now:
As a temporary work-around, this works decently:
Closing, as I'm not sure if this is actually sjstats related, or how to fix this.
I am using
tidy_stan()
within an R Notebook and the colored text does not seem to be escaping properly in the knitted notebook. Here is a toy example using brms: