我正在尝试使用rmarkdown为gitlab wiki生成markdown文档。这一切都很好,但是我想包括一些htmlwidget(例如,leaflet和reactable),这将允许额外的交互式可视化。我有以下rmarkdown文件:
---
always_allow_html: yes
output:
md_document:
variant: gfm
---
# normal plot works fine
```{r map}绘图(1:3)
`
呈现为图像而不是html表。
require(reactable)
r<-reactable(data.frame(1:4,4:1))
r
` ``
# again renders as an image
```{r}要求(单张)
leaflet()
`
This however renders both the leaflet and reactable as an image I would rather include html in my markdown. I have tried to generate the html and then use `output='asis'` but was not able to get it work. This is now the resulting document:
```javascript正常绘图工作正常
` r
绘图(1:3)
`

呈现为图像而不是html表。
` r
要求(可达)
`
## Loading required package: reactable` r
R<-可达(data.frame(1:4,4:1))
R
`

再次呈现为图像
` r
要求(单张)
`
## Loading required package: leaflet` r
leaflet()
`

请注意,我在反勾号中插入了空格,以便直观显示
发布于 2021-10-07 14:23:57
您正在尝试将HTMLwidgets显示为nonHTML文件格式,使用output: html_document是否会呈现您想要的输出?
使用output: md_document输出到.md文件

使用output: html_document输出到.html文档

使用下面的代码作为一个简单的可重现的示例。
---
always_allow_html: yes
output: html_document
---
# renders as an image and not as a html table
```{r}要求(单张)
M <- leaflet() %>%
addTiles() %>% #添加默认OpenStreetMap地图切片
addMarkers(lng=174.768,lat=-36.852,popup=“R的出生地”)
M#打印地图
https://stackoverflow.com/questions/69463508
复制相似问题