Hi all,
Is there a way to declare vectors as parameters in R. Example, I have a function(finat_DT(data)
) that returns DTtable. So here data parameter is datasets. But can we pass another arguement like finat_DT(data, column_hidden = a)
so that we can declare ````a````` as below
columnDefs = list(list(visible=FALSE, targets=a))
So when we call finat_DT(data, column_hidden = c(1,2))
#only first 2 columns gets hidden.
similarly finat_DT(data, column_hidden = c(1,2,6))
# only 1, 2 and 6 columns gets hidden
Is this possible to achieve?
Below is the sample example
library(shiny)
library(DT)
ui <- fluidPage(
dataTableOutput("tabout")
)
server <- function(input, output, session) {
small_fun <- function(data,c = a){
return(DT::datatable(data,options = list(columnDefs = list(list(visible=FALSE, targets=a)))))
}
output$tabout <- renderDataTable({
small_fun(iris,c = 3)
})
}
shinyApp(ui, server)