I'm looking for a way to adjust functions which usually show html tables in the viewer or browser in a way that they automatically insert the html in knitr documents like rnotebooks when called.
Specifically I want to change the way functions in the package sjPlot behave. At the moment they return an object with a $knitr attribute that has to be inserted manually and then produce an html table in the viewer:
`r sjt.frq(efc$e42dep, no.output=TRUE)$knitr`
One of these functions is sjt.frq. Is there a way to do this?
From knit_print:
library(knitr)
a = 42
class(a) = "my_class"
knit_print.my_class = function(x,...){
res = paste("{{", x,"}}")
asis_output(res)
}
a
It works when I knit document but doesn't work with RNotebooks and doesn't work with sjt.frq. However with RNotebook works the following statement:
library(sjPlot)
library(sjmisc)
library(knitr)
data(efc)
asis_output(sjt.frq(efc$e42dep, no.output=TRUE)$knitr)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With