Я новичок в Shiny и R.
Я делаю блестящее приложение R и печатаю DataTable.Там 14 частей (поэтому у меня есть вывод $ part0, вывод $ part1, вывод $ 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")
})}
Я думаю, что могу выполнить функцию, но пока безуспешно.