- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 Shiny 应用程序面临一个问题,其中从 csv 文件呈现的柱状数据显示在行而不是列中(除标题之外的每个变量都被视为一列,而它应该在行中对齐)。每次我访问 Shiny 页面时,都会弹出以下错误:“DataTables 警告:表 id=DataTables_Table_0 - 请求第 10 行的未知参数“10”。有关此错误的更多信息,请参阅 http://datatables.net/tn/4 ”。请参阅下面的附图
具有完全相同代码的相同应用程序在质量集群中运行得非常好,但在生产中却失败了。两处风景一模一样。请参阅下面的两张图片,了解数据的外观以及当前的显示方式。 enter image description here
该应用程序在带有 R 3.6 的 RHEL 7 上运行
Server.R
shinyServer(function(session,input, output) {
myAnalysisList = reactiveFileReader(1000, NULL, "scheduledAnalyses.csv", readFunc = read.csv, stringsAsFactors = FALSE, encoding = "UTF-8")
observeEvent(input$schedule,{
tryCatch({
adjustedDateRange<-getAdjustedDateRange(input$dateRange[1],input$dateRange[2],type = input$forecastType)
currTime = Sys.time()
print(input$forecastHorizon)
forecastHorizonCorrected = input$forecastHorizon
if(input$forecastType!="Monthly"){
forecastHorizonCorrected = input$forecastHorizonWeekly
}
newRow = data.frame(ScheduledAt = as.character(currTime),
StartDate = as.character(adjustedDateRange$startDate),
EndDate = as.character(adjustedDateRange$endDate),
Linea = input$productLinea,
Series = input$productSeries,
Group = input$productGroup,
StatGroup = input$productStatGroup,
ProductCode = input$productCode,
DemProfile = input$demandProfileSelected,
FType = input$forecastType,
FHorizon = forecastHorizonCorrected,
Status = "Scheduled",
Duration = 0)
msg="Just before writing the Schedule"
write.table(newRow,"scheduledAnalyses.csv",sep = "," ,row.names = FALSE,append = TRUE,col.names = FALSE)
output$scheduleStatus = renderUI({
box(title = "Status : Success",status = "success",width =NULL,solidHeader = TRUE,paste("Process has been scheduled at ",currTime, " ",format(currTime, format = "%Z")))
})
}, error = function(errorMsg){
output$scheduleStatus = renderUI({
box(title = "Status : Error",status = "danger", solidHeader = TRUE ,paste("Unable to schedule the process!\n Error: ",errorMsg$message,msg))
})
})
#myAnalysisList <<- bind_rows(myAnalysisList,newRow)
output$analysesList <- renderDataTable(myAnalysisList())
})
output$analysesList = renderDataTable(myAnalysisList())
# observeEvent(input$forecastHorizon,{
# print(input$forecastHorizon)
# })
UI.R
inp<-read.csv("inp.csv",stringsAsFactors = FALSE)
#-------------------------Loading data from Spark ---------------------------------#
#tbl_cache(sc,"demand_forecast_newcode_monthyr")
#inpPtr<-tbl(sc,"demand_forecast_newcode_duedate") %>% filter(linea == "Linea Differenziali DS271" | linea == "Linea Differenziali Elettronici DSE201" | linea == "Linea Differenziali Puri F200" )
#inp<-collect(inpPtr)
#columnNames<-colnames(inp)
#newNames<-sub("^.*\\.","",columnNames)
#colnames(inp)<-newNames
#View(inp)
inp<- inp[!is.na(inp$due_date), ]
inp<- inp[!is.na(inp$linea), ]
inp<- inp[!is.na(inp$series), ]
inp<- inp[!is.na(inp$groupo), ]
inp<- inp[!is.na(inp$gruppo_stat), ]
inp<- inp[!is.na(inp$productcode), ]
inp$due_date <- as.Date(inp$due_date, origin = "1970-01-01")
inpmod <- inp %>%
mutate(Year = year(due_date),
Month = month(due_date),
MonthlyDate = format(due_date, format= "%Y-%m-01"),
QuarterlyDate = quarter(due_date,with_year = TRUE),
SemesterDate = semester(due_date,with_year = TRUE),
WeekInYear = isoweek(due_date)
)
lineaChoices = c("All",unique(inpmod$linea))
serieChoices = c("All",unique(inpmod$series))
groupChoices = c("All",unique(inpmod$groupo))
statGroupChoices = c("All",unique(inpmod$gruppo_stat))
productCodeChoices = c("All",unique(inpmod$materiale))
# Define UI for application that plots random distributions
shinyUI(dashboardPage(
skin="red",
dashboardHeader(title = "Demand Forecasting, ABB Inc.", titleWidth = 350),
dashboardSidebar(
sidebarMenu(
menuItem( "Forecast", tabName = "forecastTab", icon = icon("line-chart")),
menuItem( "Status", tabName = "statusTab", icon = icon("cogs"))
)
),
dashboardBody(
tabItems(
tabItem( tabName = "forecastTab",
fluidRow(
column( width = 8,
fluidRow(
column( width = 12,
box(title = "Timeline", status = "danger", width = NULL,
dateRangeInput("dateRange","Date Range(MM-YYYY):", format = "MM-yyyy",
startview = "decade", start = "2010-01-01",end = Sys.Date())
#tags$br(),
#textOutput("AdjustedDate")
)
)
),
fluidRow(
column( width =12,
box(title = "Product Hierarchy", status = "danger", width = NULL,
column(width = 6,
selectInput("productLinea","Linea", selectize = TRUE,
choices = lineaChoices, selected = "All"),
tags$br(),
selectInput("productGroup","Group",selectize = TRUE,
choices = statGroupChoices, selected = "All"),
tags$br(),
selectInput("productCode","Product Code",selectize = TRUE,
choices =productCodeChoices, selected = "All")
),
column(width = 6,
selectInput("productSeries","Series",selectize = TRUE,
choices = serieChoices, selected = "All"),
tags$br(),
selectInput("productStatGroup","Statistical Group", selectize = TRUE,
choices = groupChoices, selected = "All")
)
)
)
)
),
column( width = 4,
box( title = "Forecast Parameters", status = "danger", width = NULL,
tags$br(),
selectInput("demandProfileSelected","Demand Profile",
choices = c("Predictable", "Unstable", "All"), selected = "Predictable"),
#tags$h4("Select the required granularity for the forecast"),
tags$br(),
selectInput("forecastType","Forecast Type", choices = c("Monthly","Weekly"),
selected = "Monthly"),
tags$hr(),
tags$br(),
#tags$h4("Select the number of time periods from end date to forecast"),
#tags$br(),
conditionalPanel("input.forecastType=='Monthly'",
sliderInput("forecastHorizon", "Forecast Horizon:", 1, 12, 6)),
conditionalPanel("input.forecastType=='Weekly'",
sliderInput("forecastHorizonWeekly", "Forecast Horizon:", 1, 52, 12))
)
)
),
fluidRow(
column(width = 2,
actionButton("clear"," Clear", class = "btn-lg btn-success",
style='color: white; width:100%; height:70px; font-size:150%;',
icon = icon("refresh"))
),
column(width = 3,
actionButton("schedule"," Schedule & Start", class = "btn-lg",
style='color: white; background-color: #dd4b39; width:100%; height:70px; font-size:150%;',
icon = icon("cogs"))
)
# column(width = 8,
# uiOutput("scheduleStatus")
# )
),
fluidRow(
tags$br(),
column(width = 3),
column( width = 6,
uiOutput("scheduleStatus")
)
)
),
tabItem(tabName = "statusTab",
#p("COmiNg sOoN")
fluidRow(
column(12,
box(title = "Scheduled Forecasts", status = "danger", width = NULL,
dataTableOutput('analysesList')
)
)
)
)
)
)
))
最佳答案
请在下面的链接中找到此问题的答案。感谢 @andresrcs ( https://community.rstudio.com/ )
有关问题的原始讨论和建议的解决方案可以在此处找到: https://github.com/rstudio/shiny/issues/2653
解决方案概要:(我测试并工作过的解决方案)对于 renderDataTable() 和 dataTableOutput() 使用 DT 包而不是 Shiny
非常感谢为问题解决做出贡献的所有人。 :)
关于r - 渲染 Shiny 页面时出现数据表问题 <DataTables warning : table id=DataTables_Table_0 - Requested unknown parameter>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58707625/
我是一名优秀的程序员,十分优秀!