html - 如何在 Jupyter (R) 中呈现 LaTeX/HTML?

标签 html xml r jupyter

我刚开始使用 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。其他人可能知道 latex 。

# 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>")

enter image description here

关于html - 如何在 Jupyter (R) 中呈现 LaTeX/HTML?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32703654/

相关文章:

html - 网站在本地主机上运行,​​上传时不显示图像

Javascript:如何将输入打印到按类选择的 <div> ?

xml - 使用 JAXB 使用 XmlElement 和 XmlAttributes 解析和 XML

r - R 中所有级别(甚至没有值的级别)的条形图

javascript - 将鼠标悬停在菜单元素上以显示子菜单

javascript - 悬停时使用CSS类显示和隐藏子div

java - 如何通过 simpleframework 解析带有没有父元素列表的 XML

xml - 根据属性比较2个节点集

python - 优化股票交易脚本

r - 如何在 R 中对向量的分组元素求和