I just started using Jupyter with R, and I\'m wondering if there\'s a good way to display HTML or LaTeX output.
Here\'s some example code that I wish worked:
Defining the following function in the session will display objects returned by xtable as html generated by xtable:
repr_html.xtable <- function(obj, ...){
paste(capture.output(print(obj, type = 'html')), collapse="", sep="")
}
library(xtable)
data(cars)
model <- lm(speed ~ ., data = cars)
xtable(model)
Without the repr_html.xtable
function, because the returned object is also of class data.frame
, the display system in the kernel will rich display that object (=html table) via repr::repr_html.data.frame
.
Just don't print(...)
the object :-)