【发布时间】:2021-01-20 12:34:37
【问题描述】:
我正在使用 R 编程语言。我正在尝试将 HTML 文件和 JPG 图像文件组合在一起。
我的代码如下所示:
library(plotly)
library(shiny)
library(magick)
#create widget_1
widget_1 = plot_ly(iris, x = ~Sepal.Length, type = "histogram", nbinsx = 20)
#upload some jpg image from your computer into R
my_image = image_read("my_image.jpg")
doc <- htmltools::tagList(
div(widget_1, style = "float:left;width:50%;"),
div(my_image,style = "float:left;width:50%;")
)
htmltools::save_html(html = doc, file = "C://Users//Me//Desktop//combined_file.html")
但是,此代码会产生以下错误:
Error in as.vector(x, "character"): cannot coerce type 'externalptr' to vector of type 'character'
是否可以在 R 中同时保存 html 和 jpg 文件?或者这根本不可能? 有没有人尝试过这样做?
谢谢
【问题讨论】:
标签: html r image widget imagemagick