r 这显示了如何将DataTables插件(在本例中为TableTools)添加到您的Shiny应用程序中。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了r 这显示了如何将DataTables插件(在本例中为TableTools)添加到您的Shiny应用程序中。相关的知识,希望对你有一定的参考价值。

library(shiny)
library(ggplot2)

# Download DataTables JS file and TableTools full package from http://datatables.net/download/
# Change the paths appropriately:
addResourcePath('datatables','/Users/yourusername/Downloads/DataTables-1.9.4/media')
addResourcePath('tabletools','/Users/yourusername/Downloads/TableTools-2.1.5/media')

runApp(list(
	ui = basicPage(
		h1('Diamonds DataTable with TableTools'),
		# Shiny imports the DataTables JS file it ships with, but after TableTools files are imported,
		# 		which causes an error. So we have to manually import the DT JS file.
		# We do this with Shiny's singletons:
		tagList( # The four core files: 3 JS files and 1 CSS file --
			singleton(tags$head(tags$script(src='/datatables/js/jquery.dataTables.js',type='text/javascript'))),
			singleton(tags$head(tags$script(src='/tabletools/js/TableTools.js',type='text/javascript'))),
			singleton(tags$head(tags$script(src='/tabletools/js/ZeroClipboard.js',type='text/javascript'))),
			singleton(tags$head(tags$link(href='/tabletools/css/TableTools.css',rel='stylesheet',type='text/css')))
		),
		dataTableOutput("mytable")
	),
	server = function(input,output) {
		output$mytable = renderDataTable({
			diamonds[,1:5]
		}, options = list(
			"sDom" = 'T<"clear">lfrtip', # "used to position the various controls"
			"oTableTools" = list(
				"sSwfPath" = "/tabletools/swf/copy_csv_xls.swf",
				# ^ "Define the path of the SWF to be used by TableTools
				# for copy to clipboard and saving a file locally operations.
				# If you are having problems with these operations, but not
				# printing, this is very likely to be the issue."
				# addResourcePath allows us to refer to /tabletools.
				"aButtons" = list(
					"copy",
					"print",
					list("sExtends" = "collection",
						 "sButtonText" = "Save",
						 "aButtons" = c("csv","xls")
					)
				)
			)
		) 
		)
	}
))

以上是关于r 这显示了如何将DataTables插件(在本例中为TableTools)添加到您的Shiny应用程序中。的主要内容,如果未能解决你的问题,请参考以下文章

如何将 XML 文件(在本例中为业务流程事件日志)导入和查询到 SQL Server Express?

jQuery 插件 DataTables:如何突出显示当前搜索文本?

如何更改 DataTables jQuery 插件的分页按钮数量

如何使用 jQuery DataTables 插件实现服务器端处理?

如何在DataTables 1.10中使用JQuery DataTables“input”插件

在 HTML 表格中显示 SqlDataSource 数据(DataTables 插件)