【发布时间】:2021-11-26 05:27:26
【问题描述】:
我在 R 中制作了一个 HTML 小部件,它使用如下 saveHTML 函数通过一系列 png 图像进行动画处理:
library(animation)
saveHTML({
# List of the images in the 'images' directory
image.list <- list.files('images', pattern = '*.png', full.names = TRUE)
# Loop through and rename this for the animation to recognise it
for (k in 1:length(image.list) ){
file.rename(image.list[k], sprintf(ani.options('img.fmt'), k))
}
}
, use.dev = FALSE, ani.width = 640, ani.height = 480, ani.type = 'png',
interval = 2, single.opts = "'dwellMultiplier': 1")
这会在我的工作目录中创建一个名为 index.html 的 html 对象。当我双击它时,会打开一个 Internet 浏览器,然后我使用控件来对“images”文件夹中的 .png 文件进行动画处理。
我的问题是,我如何在 R 闪亮的应用程序中呈现它?
【问题讨论】:
-
您可以使用
iframe将生成的 html 文件嵌入到闪亮的应用程序中。在这样做之前,您需要通过将其放在 www 文件夹中或使用addResourcePath来使 Shiny 的 Web 服务器可以使用此资源。请检查我的回答here。
标签: javascript html r shiny