【问题标题】:Datatables with HTML UI in ShinyShiny 中带有 HTML UI 的数据表
【发布时间】:2015-03-11 13:29:35
【问题描述】:

我不精通 javascript 或 jQuery,我(因此?)在 Shiny 中努力将数据表与 HTML UI 集成。我能找到的所有示例似乎都适用于 ui.r 而不是 HTML UI。

关于如何做到这一点的任何示例或建议?

(我在http://emoteer.com/ 被指出了优秀的应用程序,但我无法了解它是如何工作的)

【问题讨论】:

  • 您必须更具体地说明您遇到的问题。有各种有用的资源:@​​987654322@、herehere
  • 我面临的问题与我提到的完全一样,您发送的所有链接也表明,网络上的大多数示例都使用ui.r 构建用户界面的方式。我正在尝试构建一个 HTML UI,但我不知道如何向它提供 datatables
  • 您能否详细说明或指出来源或示例来解释您所说的HTML UI 的含义? ui.r + shiny.r 生成的页面将是 HTML - 也许您的意思是 htmlwidgets 可以在 RMarkdown 文档中使用。

标签: r datatables shiny


【解决方案1】:

你可以为index.html尝试这样的事情

<html>    
<head>
  <script src="shared/jquery.js" type="text/javascript"></script>
  <script src="shared/shiny.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="shared/shiny.css"/> 
  <script src="js/jquery.dataTables.min.js"></script>
  <link href="css/dataTables.bootstrap.css" rel="stylesheet" />
  <link href="css/dataTables.extra.css" rel="stylesheet" />
  <script src="js/dataTables.bootstrap.js"></script>
  <link href="css/bootstrap.min.css" rel="stylesheet" />
  <script src="js/bootstrap.min.js"></script>    
</head>     
<body>
  <h1>HTML UI</h1>
  <div id="table" class="shiny-datatable-output"></div>
</body>    
</html>

而在server.R

shinyServer(function(input, output, session) {

        output$table <- renderDataTable({iris})

})

您需要将 javascript、css 和图像放在 www 目录中,index.html 所在的目录。


3 月 13 日编辑 -

如果您将C:\Users\&lt;username&gt;Documents\R\win-library\3.1\shiny\www\shared 文件夹复制到其中放置index.html 文件的www 文件夹中,那么下面应该处理它。

<head>
  <script src="shared/jquery.js" type="text/javascript"></script>
  <script src="shared/shiny.js" type="text/javascript"></script>
  <link   rel="stylesheet" type="text/css" href="shared/shiny.css"/> 

  <link href="shared/datatables/css/dataTables.bootstrap.css" rel="stylesheet" />
  <link href="shared/datatables/css/dataTables.extra.css" rel="stylesheet" />
  <script src="shared/datatables/js/jquery.dataTables.min.js"></script>
  <script src="shared/datatables/js/dataTables.bootstrap.js"></script>

  <link href="shared/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
  <script src="shared/bootstrap/js/bootstrap.min.js"></script>    
</head> 

【讨论】:

  • 谢谢,@NicE!我在您的答案下方添加了一个傻瓜版本,因为您列出的某些文件夹路径似乎与我的不同。如果它不值得一个单独的问题,你能告诉我为什么dataTableOutput 根本不需要吗?我尝试了与您的代码类似的方法,但一直收到警告。
猜你喜欢
  • 1970-01-01
  • 2015-02-25
  • 1970-01-01
  • 2020-04-14
  • 1970-01-01
  • 2019-03-08
  • 1970-01-01
  • 1970-01-01
  • 2018-07-29
相关资源
最近更新 更多