我似乎无法弄清楚这个问题,因为我在闪亮的应用程序中有一个数据表... renderDatatable顶部的过滤器看上去很扭曲。见下文:
示例数据和代码:
roadsalt_data<-structure(list(orgid = c("NJDEP_BFBM", "NJDEP_BFBM", "NJDEP_BFBM",
"NJDEP_BFBM", "NJDEP_BFBM", "BTMUA", "NJDEP_BFBM", "BTMUA", "USGS-NJ",
"BTMUA"), locid = c("NJDEP_BFBM-NJW04459-254-1", "NJDEP_BFBM-NJW04459-254-1",
"NJDEP_BFBM-NJW04459-254-1", "NJDEP_BFBM-NJW04459-254-1", "NJDEP_BFBM-NJW04459-254-1",
"BTMUA-INTAKE", "NJDEP_BFBM-NJW04459-254-2", "BTMUA-INTAKE",
"USGS-01378600", "BTMUA-INTAKE"), stdate = structure(c(15664,
15664, 15664, 15664, 15664, 14173, 15664, 14174, 13570, 14176
), class = "Date"), sttime = structure(c(43560, 43680, 43740,
43380, 43260, 40920, 45000, 36420, 37200, 37800), class = c("hms",
"difftime"), units = "secs"), charnam = c("Specific conductance",
"Specific conductance", "Specific conductance", "Specific conductance",
"Specific conductance", "Specific conductance", "Specific conductance",
"Specific conductance", "Specific conductance", "Specific conductance"
), val = c(26200, 26200, 26200, 25700, 23800, 23039, 22000, 20981,
16000, 15543), valunit = c("uS/cm @25C", "uS/cm @25C", "uS/cm @25C",
"uS/cm @25C", "uS/cm @25C", "uS/cm @25C", "uS/cm @25C", "uS/cm @25C",
"uS/cm @25C", "uS/cm @25C"), swqs = c("FW2-NT", "FW2-NT", "FW2-NT",
"FW2-NT", "FW2-NT", "FW2-NT", "FW2-NT", "FW2-NT", "FW2-NT", "FW2-NT"
), WMA = c(5L, 5L, 5L, 5L, 5L, 13L, 5L, 13L, 5L, 13L), year = c(2012L,
2012L, 2012L, 2012L, 2012L, 2008L, 2012L, 2008L, 2007L, 2008L
), locid2 = c("NJW04459-254-1", "NJW04459-254-1", "NJW04459-254-1",
"NJW04459-254-1", "NJW04459-254-1", "INTAKE", "NJW04459-254-2",
"INTAKE", "01378600", "INTAKE")), .Names = c("orgid", "locid",
"stdate", "sttime", "charnam", "val", "valunit", "swqs", "WMA",
"year", "locid2"), row.names = c(NA, -10L), class = c("tbl_df",
"tbl", "data.frame"))
library(shiny)
library(shinydashboard)
header<- dashboardHeader()
sidebar<- dashboardSidebar()
body<- dashboardBody(DT::dataTableOutput("Table1"))
ui<-dashboardPage(header, sidebar, body)
server<- function(input,output,session){
output$Table1<- DT::renderDataTable({
DT::datatable(roadsalt_data,filter = 'top')
})
}
shinyApp(ui = ui, server = server)
答案 0 :(得分:0)
当您的应用无法正确显示在屏幕上时,就会发生这种情况。这是我15英寸笔记本电脑上的样子:
但是,如果我放大(类似在较小的屏幕上),则会发生失真。您可以将代码编辑为以下内容,它应该创建一个滚动条而不是使其失真:
DT::datatable(roadsalt_data,filter = 'top', options = list(scrollX = TRUE))
更新
包含完整代码
roadsalt_data<-structure(list(orgid = c("NJDEP_BFBM", "NJDEP_BFBM", "NJDEP_BFBM",
"NJDEP_BFBM", "NJDEP_BFBM", "BTMUA", "NJDEP_BFBM", "BTMUA", "USGS-NJ",
"BTMUA"), locid = c("NJDEP_BFBM-NJW04459-254-1", "NJDEP_BFBM-NJW04459-254-1",
"NJDEP_BFBM-NJW04459-254-1", "NJDEP_BFBM-NJW04459-254-1", "NJDEP_BFBM-NJW04459-254-1",
"BTMUA-INTAKE", "NJDEP_BFBM-NJW04459-254-2", "BTMUA-INTAKE",
"USGS-01378600", "BTMUA-INTAKE"), stdate = structure(c(15664,
15664, 15664, 15664, 15664, 14173, 15664, 14174, 13570, 14176
), class = "Date"), sttime = structure(c(43560, 43680, 43740,
43380, 43260, 40920, 45000, 36420, 37200, 37800), class = c("hms",
"difftime"), units = "secs"), charnam = c("Specific conductance",
"Specific conductance", "Specific conductance", "Specific conductance",
"Specific conductance", "Specific conductance", "Specific conductance",
"Specific conductance", "Specific conductance", "Specific conductance"
), val = c(26200, 26200, 26200, 25700, 23800, 23039, 22000, 20981,
16000, 15543), valunit = c("uS/cm @25C", "uS/cm @25C", "uS/cm @25C",
"uS/cm @25C", "uS/cm @25C", "uS/cm @25C", "uS/cm @25C", "uS/cm @25C",
"uS/cm @25C", "uS/cm @25C"), swqs = c("FW2-NT", "FW2-NT", "FW2-NT",
"FW2-NT", "FW2-NT", "FW2-NT", "FW2-NT", "FW2-NT", "FW2-NT", "FW2-NT"
), WMA = c(5L, 5L, 5L, 5L, 5L, 13L, 5L, 13L, 5L, 13L), year = c(2012L,
2012L, 2012L, 2012L, 2012L, 2008L, 2012L, 2008L, 2007L, 2008L
), locid2 = c("NJW04459-254-1", "NJW04459-254-1", "NJW04459-254-1",
"NJW04459-254-1", "NJW04459-254-1", "INTAKE", "NJW04459-254-2",
"INTAKE", "01378600", "INTAKE")), .Names = c("orgid", "locid",
"stdate", "sttime", "charnam", "val", "valunit", "swqs", "WMA",
"year", "locid2"), row.names = c(NA, -10L), class = c("tbl_df",
"tbl", "data.frame"))
library(shiny)
library(shinydashboard)
header<- dashboardHeader()
sidebar<- dashboardSidebar()
body<- dashboardBody(DT::dataTableOutput("Table1"))
ui<-dashboardPage(header, sidebar, body)
server<- function(input,output,session){
output$Table1<- DT::renderDataTable({
DT::datatable(roadsalt_data,filter = 'top', options = list(scrollX = TRUE))
})
}
shinyApp(ui = ui, server = server)