gpt4 book ai didi

javascript - R Shiny RenderDataTable 显示选项

转载 作者:行者123 更新时间:2023-11-29 14:51:24 26 4
gpt4 key购买 nike

Shiny Output]

所以我有了这张使用 ShinyDash 包制作的表格。鉴于记录数量较少,我想删除页码并只显示上一页/下一页。我还想删除左上角的框以选择每页的记录数,并将其默认为 5。

这是我当前的代码,尽管最后一行带有选项才是最重要的:

output$values <- renderDataTable({ 
}
df <- data.frame(
Period = c("SP15", "FA14", "SU14", "SP14", "FA13", "SP13"),
StartedApps = c(full$Cum[full$Day == as.numeric(elapsed) & full$Group == "SP15"],
full$Cum[full$Day == as.numeric(elapsed) & full$Group == "FA14"],
full$Cum[full$Day == as.numeric(elapsed) & full$Group == "SU14"],
full$Cum[full$Day == as.numeric(elapsed) & full$Group == "SP14"],
full$Cum[full$Day == as.numeric(elapsed) & full$Group == "FA13"],
full$Cum[full$Day == as.numeric(elapsed) & full$Group == "SP13"]),
Pct = c("",
percent(full$Cum[full$Day == as.numeric(elapsed) & full$Group == "SP15"]/full$Cum[full$Day == as.numeric(elapsed) & full$Group == "FA14"] - 1),
percent(full$Cum[full$Day == as.numeric(elapsed) & full$Group == "SP15"]/full$Cum[full$Day == as.numeric(elapsed) & full$Group == "SU14"] - 1),
percent(full$Cum[full$Day == as.numeric(elapsed) & full$Group == "SP15"]/full$Cum[full$Day == as.numeric(elapsed) & full$Group == "SP14"] - 1),
percent(full$Cum[full$Day == as.numeric(elapsed) & full$Group == "SP15"]/full$Cum[full$Day == as.numeric(elapsed) & full$Group == "FA13"] - 1),
percent(full$Cum[full$Day == as.numeric(elapsed) & full$Group == "SP15"]/full$Cum[full$Day == as.numeric(elapsed) & full$Group == "SP13"] - 1)),
CompletedApps = c(fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "SP15"],
fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "FA14"],
fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "SU14"],
fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "SP14"],
fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "FA13"],
fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "SP13"]),
Pct2 = c("",
percent(fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "SP15"]/fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "FA14"] - 1),
percent(fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "SP15"]/fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "SU14"] - 1),
percent(fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "SP15"]/fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "SP14"] - 1),
percent(fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "SP15"]/fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "FA13"] - 1),
percent(fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "SP15"]/fullcomp$Cum[fullcomp$Day == as.numeric(elapsed) & fullcomp$Group == "SP13"] - 1)))

df$Pct <- recode(df$Pct, "'Inf%' = 'NA'")
df$Pct2 <- recode(df$Pct2, "'Inf%' = 'NA'")
df$StartedApps <- as.integer(df$StartedApps)
df$CompletedApps <- as.integer(df$CompletedApps)
names(df) <- c("Period", "Starts", "Pct Change", "Submits", "Pct Change")
df
}, options = list(pagingType = "simple", bFilter = FALSE, aLengthMenu = 5, iDisplayLength = 5))

该应用程序构建在 DataTables JavaScript 库 ( http://datatables.net/reference/option/ ) 上,但我对 JavaScript 的了解还不足以弄明白:(有什么想法吗?

最佳答案

您可以使用 sPaginationType 选项。在更高版本的 data.table (1.10) 中,pagingType http://datatables.net/reference/option/pagingType 具有更大的灵 active :

library(shiny)
runApp(list(
server = function(input, output, session) {
output$dt <- renderDataTable({
data = data.frame(setNames(replicate(15, rnorm(100), simplify = FALSE), letters[1:15]))
return(data)
},
options =
list(sPaginationType = "two_button")
)
}
, ui = navbarPage("Foo", id="page", collapsable=TRUE, inverse=FALSE,
tabPanel("Bar",
dataTableOutput("dt")
)
)
)
)

关于javascript - R Shiny RenderDataTable 显示选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25126130/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com