html - 如何在 R 中打印 HTML
问题描述
我有这个
<div style="margin:auto;text-align:center">
<strong>Types per year</strong>
<br/>
<div id="htmlwidget-342a290aea162ba34746" class="streamgraph html-widget" style="width:960px;height:500px;"></div>
<div id="htmlwidget-342a290aea162ba34746-legend" style="width:960" class="streamgraph html-widget-legend"><center><label style='padding-right:5px' for='htmlwidget-342a290aea162ba34746-select'></label><select id='htmlwidget-342a290aea162ba34746-select' style='visibility:hidden;'></select></center></div>
<script type="application/json" data-for="htmlwidget-342a290aea162ba34746">{"x":{"data":{"key":["Industrial.compound","Pesticide","Pharmaceutical","Industrial.compound","Pesticide","Pharmaceutical","Industrial.compound","Pesticide","Pharmaceutical","Industrial.compound","Pesticide","Pharmaceutical"],"value":[3.21469787709497,0.312979157894737,0.124318181818182,2.60063721925134,0.268401470588235,0.145491329479769,3.80744464705882,0.51568,0.2358755,0.51034125,0.297461538461538,0],"date":["2015-04-24","2015-04-24","2015-04-24","2016-04-24","2016-04-24","2016-04-24","2017-04-24","2017-04-24","2017-04-24","2018-04-24","2018-04-24","2018-04-24"]},"markers":null,"annotations":null,"offset":"silhouette","interactive":true,"interpolate":"cardinal","palette":"Spectral","text":"black","tooltip":"black","x_tick_interval":1,"x_tick_units":"yr","x_tick_format":"%Y","y_tick_count":0,"y_tick_format":",g","top":20,"right":40,"bottom":30,"left":50,"legend":true,"legend_label":"Type: ","fill":"brewer","label_col":"black","x_scale":"date"},"evals":[],"jsHooks":[]}</script>
</div>
我想在 R 中打印绘图,但我不知道如何使用 html 来打印。
你能帮助我吗?
解决方案
由于您将其标记为 Shiny,我将假设您希望在闪亮的应用程序中包含原始 HTML。在这种情况下,您可以使用 HTML 标签
library(shiny)
# add the below in your ui.R script
tags$div(
HTML( <your raw HTML goes here> )
)
有关更多详细信息,请参阅https://shiny.rstudio.com/articles/html-tags.html,向下滚动到“原始 HTML”部分。
推荐阅读
- c# - EPPlus LoadingFromCollection 将对象的 toString 用于列
- r - R为每个参与者的每个条件选择n行
- javascript - 如何获取原始日期编号?
- java - Java 8 LocalDateTime 和 ZonedDateTime 转换
- html - 错误地将焦点移动到字段时,如何允许屏幕阅读器宣布 ASP.NET MVC 5 表单验证消息?
- javascript - 如果条件不满足,则不会呈现任何内容的模板文字
- random - 如何在立方体中创建均匀随机分布的球体?
- scala - Spark - 加入后聚合列从 DataFrame 中消失
- javascript - 关闭以 vue-cli 3 (webpack 4.15.1) 开始的项目的热重载
- java - 为什么如果我使用循环作为输入,算法会更慢