微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在Jupyter(R)中渲染LaTeX / HTML?

我刚开始使用Jupyter和R,我想知道是否有一种很好的方式来显示 HTML或LaTeX输出.

这是我希望工作的一些示例代码

library(xtable)
x <- runif(500,1,50)
y <- x + runif(500,-5,5)
model <- lm(y~x)
print(xtable(model),type = 'html')

它只是将其显示为纯文本,而不是呈现HTML.有没有办法改变这种行为?

解决方法

repr(用于设置选项)和IRdisplay的组合将适用于HTML.其他人可能知道乳胶.
# Cell 1 ------------------------------------------------------------------

library(xtable)
library(IRdisplay)
library(repr)

data(tli)
tli.table <- xtable(tli[1:20,])
digits(tli.table) <- matrix( 0:4,nrow = 20,ncol = ncol(tli)+1 )

options(repr.vector.quote=FALSE)

display_html(paste(capture.output(print(head(tli.table),type = 'html')),collapse="",sep=""))


# Cell 2 ------------------------------------------------------------------

display_html("<span style='color:red; float:right'>hello</span>")

# Cell 3 ------------------------------------------------------------------

display_markdown("[this](http://google.com)")

# Cell 4 ------------------------------------------------------------------

display_png(file="shovel-512.png")

# Cell 5 ------------------------------------------------------------------

display_html("<table style='width:20%;border:1px solid blue'><tr><td style='text-align:right'>cell 1</td></tr></table>")

原文地址:https://www.jb51.cc/html/226111.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐