How to render LaTeX / HTML in Jupyter (R)?

后端 未结 5 532
感情败类
感情败类 2020-12-11 04:26

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:

5条回答
  •  时光取名叫无心
    2020-12-11 04:54

    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 :-)

提交回复
热议问题