闪亮的功能数据表

时间:2018-10-10 14:25:53

标签: r function datatable shiny

我是Shiny和R的初学者。

我正在做一个R Shiny应用程序,并打印一个DataTable。有14个部分(所以我有output $ part0,output $ part1,output $ part2,...)它们是相同的,唯一的区别是输入中的数据(p0,p1,p2,p3,...)。我正在尝试减少代码,因为现在我在服务器中重复相同的代码。R

output$part0 <- function(X) {DT::renderDataTable({
DT::datatable(p0, selection='none',
              class="display compact",
              options = list(pageLength = 20,dom = 't',
                             autoWidth = FALSE,
                             width="100%",
                             ordering=FALSE ,
                             columnDefs =list(list(className = 'dt-center', targets = 1))
              ),
              rownames=FALSE,
              colnames=NULL
)%>% formatStyle (column=c(1),fontWeight='italic') %>% formatStyle 
 (c("Colum2"), 

backgroundColor = styleEqual(c('More', 'Less'),c('rgb(11,83,69)', 'rgb(151,154,154)'
                                                                                                 )
                                                                    )
) %>% formatStyle (c("Etat"), fontStyle = styleEqual (c("More"), c("italic")))%>% formatStyle(columns=2, color="white")
  })}  







output$part1 <- function(X) {DT::renderDataTable({
DT::datatable(p1, selection='none',
              class="display compact",
              options = list(pageLength = 20,dom = 't',
                             autoWidth = FALSE,
                             width="100%",
                             ordering=FALSE ,
                             columnDefs =list(list(className = 'dt-center', targets = 1))
              ),
              rownames=FALSE,
              colnames=NULL
)%>% formatStyle (column=c(1),fontWeight='italic') %>% formatStyle 
 (c("Colum2"), 

backgroundColor = styleEqual(c('More', 'Less'),c('rgb(11,83,69)', 'rgb(151,154,154)'
                                                                                                 )
                                                                    )
) %>% formatStyle (c("Etat"), fontStyle = styleEqual (c("More"), c("italic")))%>% formatStyle(columns=2, color="white")
  })}  

我想我可以执行某项功能,但还没有成功。

0 个答案:

没有答案