问题描述
我正在使用 R 编程语言.我有兴趣学习如何保存几个html 小部件".一起.我已经能够手动创建不同类型的 html 小部件:
I am using the R programming language. I am interested in learning how to save several "html widgets" together. I have been able to manually create different types of html widgets:
小部件 2:
小部件 3:
小部件 4:
从这里,我发现了另一个 stackoverflow 帖子,其中提出了类似的问题:使用R和plot.ly,如何将多个htmlwidgets保存到我的html中?
From here, I found another stackoverflow post where a similar question was asked: Using R and plot.ly, how to save multiples htmlwidgets to my html?
在这篇文章中,它解释了如何将多个 html 小部件保存在一起 - 回答问题的人编写了一个函数来这样做:
In this post, it explains how to save several html widgets together - the person who answered the question wrote a function to do so:
我尝试使用此功能将 4 个小部件保存在一起:
I tried using this function to save the 4 widgets together:
但是这样做,我得到了以下错误:
But doing so, I got the following error:
有没有一种直接简单的方法可以将多个 html 小部件保存在一起?
Is there a straightforward and simple way for saving multiple html widgets together?
谢谢
注意:我知道您可以在 R 中使用 combineWidgets() 函数:
NOTE: I know that you can use the combineWidgets() function in R:
但是,我使用的计算机没有互联网接入或 USB 端口.这台计算机预装了带有有限库的 R 副本(它包含我的问题中使用的所有库,除了manipulateWidget").我正在寻找将多个 html 小部件保存在一起的最简单方法(例如,这在 base R 中是否可行)?
However, I am working with a computer that has no internet access or USB ports. This computer has a pre-installed copy of R with limited libraries (it has all the libraries used throughout my question except "manipulateWidget"). I am looking for the simplest way to save multiple html widgets together (e.g. is this possible in base R)?
谢谢
推荐答案
如果格式不重要,可以使用tagList合并widget,直接保存:
If format doesn't matter too much, you can merge the widgets using tagList and save them directly:
(不用说您需要编辑文件路径!)
(It goes without saying that you will need to edit the filepath!)
如果要控制小部件的布局,可以将每个小部件包装在一个 div 中,然后设置它们的样式:
If you want to control the layout of the widgets, you can wrap each in a div, and then style those:
这篇关于R:将多个 html 小部件保存在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!