Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sorting 具有多个输入的闪亮表格_Sorting_Input_Shiny - Fatal编程技术网

Sorting 具有多个输入的闪亮表格

Sorting 具有多个输入的闪亮表格,sorting,input,shiny,Sorting,Input,Shiny,我想在具有多个输入的数据集下面创建一个闪亮的输出表。 我想选择车型、细分市场和年份。我该怎么做?有没有一种方法可以让你放置一个按钮并对显示的数据进行排序? 多谢各位 df=data.frame(year=c(2018,2018,2017,2017,2017),model=c("mazda","ford","ford" ,"toyotta","mazda"),segment=c("c1","ax","ay","gv","c1"),sales=c(23,54,65,78,54)) 奇妙的库(DT)

我想在具有多个输入的数据集下面创建一个闪亮的输出表。 我想选择车型、细分市场和年份。我该怎么做?有没有一种方法可以让你放置一个按钮并对显示的数据进行排序? 多谢各位

df=data.frame(year=c(2018,2018,2017,2017,2017),model=c("mazda","ford","ford"
,"toyotta","mazda"),segment=c("c1","ax","ay","gv","c1"),sales=c(23,54,65,78,54))

奇妙的
库(DT)
满足所有上述要求,无需定义任何输入或自定义过滤器逻辑:

library(shiny)
library(DT)

ui <- basicPage(
  h2("Car data"),
  DT::dataTableOutput("mytable")
)

server <- function(input, output) {

  df = data.frame(
    year = c(2018, 2018, 2017, 2017, 2017),
    model = c("mazda", "ford", "ford"
              , "toyotta", "mazda"),
    segment = c("c1", "ax", "ay", "gv", "c1"),
    sales = c(23, 54, 65, 78, 54)
  )

  output$mytable = DT::renderDataTable({
    df
  }, filter = "top", options = list(pageLength = 30))
}

shinyApp(ui, server)
库(闪亮)
图书馆(DT)

ui谢谢,但年专栏我只能看到20个。我怎样才能把它变大?不知道你的目标是什么?请参阅附件中的屏幕截图。您可能正在谈论显示的行数?您可以设置pageLength选项。此外,您还可以使用分页按钮在表格中导航。我将示例编辑为pageLength=30,但在您提供的数据中只有5行可用。