Add Values to a Reactive Table in Shiny

Add values to a reactive table in shiny

I think you want to use reactiveValues() to store your data frame. Here is a possible solution:

library(shiny)

runApp(list(
ui=pageWithSidebar(headerPanel("Adding entries to table"),
sidebarPanel(textInput("text1", "Column 1"),
textInput("text2", "Column 2"),
actionButton("update", "Update Table")),
mainPanel(tableOutput("table1"))),
server=function(input, output, session) {
values <- reactiveValues()
values$df <- data.frame(Column1 = NA, Column2 = NA)
newEntry <- observe({
if(input$update > 0) {
newLine <- isolate(c(input$text1, input$text2))
isolate(values$df <- rbind(values$df, newLine))
}
})
output$table1 <- renderTable({values$df})
}))

Edit

To avoid creating an empty row, create an empty data.frame rather than one with NA:

values$df <- data.frame(Column1 = numeric(0), Column2 = numeric(0))

And indexing seems better for adding the rows than rbind() (which messes up the column names... not sure why):

isolate(values$df[nrow(values$df) + 1,] <- c(input$text1, input$text2))

Another Follow up to “add values to a reactive table in Shiny” when we already have a dataframe

There are multiple issues with your code. You start reactiveValues but you never assign anything to it so no data could hope to be reactive. Also, you likely want to use observeEvent so that each time you hit the Update button you get a response. You can also isolate blocks of code. Furthermore, you should use a data.frame for your new data as the 'type' of the data matters (i.e. numeric, character, etc.). The following works well for me.

library(shiny)

runApp(
list(
ui = fluidPage(

pageWithSidebar(
headerPanel("Adding entries to table"),
sidebarPanel(
numericInput("num2", "Column 2", value = 0),

actionButton("update", "Update Table")),
mainPanel(tableOutput("table1")))
),
server = function(input, output, session) {

values <- reactiveValues(
dm = data.frame(Date = as.Date(c("2015-05-10", "2015-10-07", "2015-03-26","2015-07-18")),
Col2 = c(160, 150, 121, 93))
)

addData <- observeEvent(input$update, {
values$dm <- isolate({
newLine <- data.frame(Date = format(Sys.time(), "%Y-%m-%d"),
Col2 = tail(values$dm$Col2, n=1) - 4)
rbind(values$dm,newLine)
})
})

output$table1 <- renderTable({
values$dm
})
}
)
)

Follow up to add values to a reactive table in Shiny

The solution for me was to not create that first row, but instead to make a data.frame with empty rows. As an aside it also seems to be better to use indexing rather than rbind():

library(shiny)

runApp(list(
ui=pageWithSidebar(headerPanel("Adding entries to table"),
sidebarPanel(textInput("text1", "Column 1"),
textInput("text2", "Column 2"),
actionButton("update", "Update Table")),
mainPanel(tableOutput("table1"))),
server=function(input, output, session) {
values <- reactiveValues()
#Create 0 row data.frame
values$df <- data.frame(Column1 = numeric(0), Column2 = numeric(0))
newEntry <- observe({
if(input$update > 0) {
isolate(values$df[nrow(values$df) + 1,] <- c(input$text1, input$text2))
}
})
output$table1 <- renderTable({values$df})
}))

How to create a table in a reactive object in Shiny

That happens because reactive() does not return a data frame but returns a vector of length one. Use reactiveValues() instead.

library(shiny)

ui <- fluidPage(
tableOutput("first"),
sliderInput("num","choose num",1,10,1)
)

server <- function(input, output, session) {

# t1 = (as.data.frame(forecast %>% filter(Date==Sys.Date()-21) %>% group_by(Resort,Date) %>% summarise(`Powder Total` = sum(Snow))))
# t1=t1[order(t1$`Powder Total`,decreasing=TRUE),][1:5,]

# output$first = renderTable({
# t1[1,]
# })

tableData = reactiveValues(d1 = as.data.frame(matrix(nrow=2,ncol = 2)))

observeEvent(input$num, {

temp = tableData$d1
names(temp)=c("col1","col2")
temp$col1=input$num
temp$col2=input$num+1

tableData$d1 = temp

})

test = reactive({
d1 = as.data.frame(matrix(nrow=2,ncol = 2))
names(d1)=c("col1","col2")
d1$col1=input$num
d1$col2=input$num+1
})

output$first=renderTable({
tableData$d1
})

observe({print(test())}) # check console output
observe({print(tableData$d1)}) # check console output

observe({print(is.data.frame(test()))
print(is.data.frame(tableData$d1))

})
}

shinyApp(ui, server)

I've included a few observe calls for you to see that test() is not a dataframe.

Sample Image

In R shiny how to render a reactive data table?

Mistake was to use show("table1") instead of tableOutput("table1") in the last observeEvent in the original MWE code posted above. Also two custom functions in the original MWE were erroneously omitted: "pct" and "vectorPlot". Revised MWE code below now uses the correct table output syntax and includes all required functions. Now it runs as intended. Thanks to YBS comment for pointing out the error.

library(shiny)
library(shinyMatrix)
library(shinyjs)

button2 <- function(x,y){actionButton(x,y,style="width:90px;margin-bottom:5px;font-size:80%")}

matrix1Input <- function(x){
matrixInput(x,
value = matrix(c(0.2), 4, 1, dimnames = list(c("A","B","C","D"),NULL)),
rows = list(extend = FALSE, names = TRUE),
cols = list(extend = FALSE, names = FALSE, editableNames = FALSE),
class = "numeric")}

pct <- function(x){paste(format(round(x*100,digits=1),nsmall=1),"%",sep="")} # convert to percentage

vectorBase <- function(x,y){
a <- rep(y,x)
b <- seq(1:x)
c <- data.frame(x = b, y = a)
return(c)}

vectorPlot <- function(w,x,y,z){plot(w,main=x,xlab=y,ylab=z,type="b",col="blue",pch=19,cex=1.25)}

ui <-
pageWithSidebar(
headerPanel("Model..."),
sidebarPanel(
fluidRow(helpText(h5(strong("Base Input Panel")),align="center",
style="margin-top:-15px;margin-bottom:5px")),
# Panels rendered with uiOuput & renderUI in server to stop flashing at invocation
uiOutput("Panels")
), # close sidebar panel
mainPanel(
tabsetPanel(
tabPanel("By balances", value=2,
fluidRow(h5(strong(helpText("Select model output to view:")))),
fluidRow(
button2('showVectorPlotBtn','Vector plots'),
button2('showVectorValueBtn','Vector values'),
), # close fluid row

div(style = "margin-top: 5px"),

# Shows outputs on each page of main panel
uiOutput('showResults'),
), # close tab panel
tabPanel("By accounts", value=3),
tabPanel("Liabilities module", value=4),
id = "tabselected"
) # close tabset panel
) # close main panel
) # close page with sidebar

server <- function(input,output,session)({

base_input <- reactive(input$base_input)
showResults <- reactiveValues()

yield <- function(){vectorBase(60,input$base_input[1,1])} # Must remain in server section

# --- Conditional panels rendered here rather than in UI to eliminate invocation flashing ---------->
output$Panels <- renderUI({
tagList(
conditionalPanel(
condition="input.tabselected==2",
matrix1Input("base_input"),
div(style = "margin-top: 0px"),
useShinyjs(),
), # close conditional panel
conditionalPanel(condition="input.tabselected==3"),
conditionalPanel(condition="input.tabselected==4")
) # close tagList
}) # close renderUI

# --- Below produces vector plots as default view when first invoking App ----------------------------->
output$graph1 <-renderPlot(vectorPlot(yield(),"A Variable","Period","Rate"))

# --- Below produces vector plots after having clicked "Vector Plot" button; see above for pre-click ->
observeEvent(input$showVectorPlotBtn,
{showResults$showme <-
tagList(plotOutput("graph1"))
},ignoreNULL = FALSE)

# --- Below produces vector values table ------------------------------------------------------------->
vectorsAll <- reactive({cbind(Period = 1:60,Yld_Rate = pct(yield()[,2]))})

output$table1 <- renderTable({vectorsAll()})

observeEvent(input$showVectorValueBtn,{showResults$showme <- tableOutput("table1")})

# --- Below sends both vector plots and vector values to UI section above ---------------------------->
output$showResults <- renderUI({showResults$showme})

}) # close server

shinyApp(ui, server)

How to add rows to R Shiny table

You need to use a reactive xyTable in order for the output to update. Also,
append the rows inside an observer rather than a reactive expression, and make sure to save the updated reactive value:

library(shiny)
library(tidyverse)

ui <- fluidPage(
sidebarPanel(
numericInput("x", "Enter Value of X", 1),
numericInput("y", "Enter Value of Y", 1),
actionButton("add_data", "Add Data", width = "100%")
),
mainPanel(
tableOutput("xy_Table")
)
)

server <- function(input, output, session) {
xyTable <- reactiveVal(
tibble(x = numeric(), y = numeric())
)

observeEvent(input$add_data, {
xyTable() %>%
add_row(
x = input$x,
y = input$y,
) %>%
xyTable()
})

output$xy_Table <- renderTable(xyTable())
}

shinyApp(ui, server)

Modify a column of a reactive data table in Shiny

This should get you some of the way. Let me know what is still needed. See Unable to pass user inputs into R shiny modules. The main point is that you need to pass inputs from the main app as reactives to the module.

library(lubridate)
library(shiny)
library(shinyjs)
library(tidyverse)
library(DT)

test_data<- data.frame(matrix(data=round(rnorm(8*5),2),ncol=8,nrow=5))

mod_data <- function(input, output, session, data_in, var_1) {

data_x <- reactiveValues(
data=data_in
)
proxy = dataTableProxy("data_in")

# observe({
# newvar <- var_1()
# data_x$data[, 1] <<- newvar
# replaceData(proxy, data_x$data, resetPaging = FALSE)
# })

observeEvent(var_1(), {
isolate(data_x$data[1, 1] <<- var_1())
replaceData(proxy, data_x$data, resetPaging = FALSE) # replaces data displayed by the updated table
})

#manual element update
observeEvent(input$data_mod_cell_edit, {
info = input$data_mod_cell_edit
str(info)
i = info$row
j = info$col+1
k = info$value
str(info)

isolate(
if (j %in% match(c("X1","X2"), names(data_x$data))) {
data_x$data[i, j] <<- DT::coerceValue(k, data_x$data[i, j])
}
)
replaceData(proxy, data_x$data, resetPaging = FALSE) # replaces data displayed by the updated table
})

output$data_mod <- DT::renderDataTable({
DT::datatable(
data=data_x$data,
editable = TRUE,
rownames = FALSE,
class="compact cell-border",
selection = list(mode = "single",
target = "row"
),
options = list(
dom="t",
autoWidth=TRUE,
scrollX = TRUE,
ordering=FALSE,
pageLength = 16,
bLengthChange= FALSE,
searching=FALSE
)
)
})

}

modFunctionUI <- function(id) {
ns <- NS(id)
DT::dataTableOutput(ns(id))
}

# Define UI
#ui----
ui= fluidPage(
fluidRow(
br(),
br(),
column(1,selectInput(inputId="var_1", label = h5("var 1"), choices=c(555,444),selected = 555)),
column(4, tableOutput("data")),
column(4, modFunctionUI("data_mod"))
),
#set font size of tables
useShinyjs(),
inlineCSS(list("table" = "font-size: 12px"))
)

#shiny server ----
server=function(input,output,session){

#normal table
global <- reactiveValues( df =test_data )
observe({ global$df$X1 <- input$var_1 })
output$data <- renderTable({global$df })

#datatable
callModule(module=mod_data,
id="data_mod",
data_in=test_data,
var_1=reactive(input$var_1)
)
}
# Run the application
shinyApp(ui = ui, server = server)

r shiny - apply function to reactive data table

  1. How can I apply a function cleanup defined above to the set of columns selected in the pickerInput?

See example code bellow


  1. Is an actionButton the best way to do so?

Really up to you


  1. If I need to use the data I passed through the cleanup function, does making the datatable reactive inefficient?

Hard to say without knowing more about your data

Example code:

library(shiny)
library(shinyWidgets)
library(dplyr)

cleanup <- function(x) {
mean(x, na.rm = TRUE)
}

ui <- basicPage(
pickerInput(width = "75%",
inputId = "pick_col1",
label = "Select the columns of table 1 you wish to display:",
choices = colnames(iris)[1:4],
selected = colnames(iris)[1:4],
options = list(
`actions-box` = TRUE,
`selected-text-format` = paste0("count > ", length(colnames(iris)) - 1),
`count-selected-text` = "Alle",
liveSearch = TRUE,
liveSearchPlaceholder = TRUE
),
# build buttons for collective selection
multiple = TRUE
),
tags$hr(),
column(width = 5, h2("Selected columns"), tableOutput("raw_data")),
column(width = 1),
column(
width = 5,
h2("Processed selected columns"),
actionButton("cleanup", "Clean up"),
tableOutput("mean_data")
)
)

server <- function(input, output) {
# show the selected columns (plus the grouping variable)
output$raw_data <- renderTable({
iris %>% select(Species, input$pick_col1) %>%
group_by(Species) %>%
top_n(n = 2)
})

# button to run the processing function.
# In this case just get the mean per Iris species
# make it just reactive (or include inside renderTable below)
# if actionButton is not desired
clean_df <- eventReactive(input$cleanup, {
iris %>% select(Species, input$pick_col1) %>%
group_by(Species) %>%
summarise_all(.funs =list(cleanup))
})

# show the processed columns
output$mean_data <- renderTable({
clean_df()
})

}
shinyApp(ui, server)

EDIT: Two tables in two tabs with two input pickers, no action buttons

library(shiny)
library(shinyWidgets)
library(dplyr)

cleanup <- function(x) {
mean(x, na.rm = TRUE)
}

ui <- basicPage(tabsetPanel(
id = "tabs",
tabPanel(
title = "Table 1",
value = "tab1",
wellPanel(
pickerInput(
width = "75%",
inputId = "pick_col1",
label = "Select the columns of table 1 you wish to display:",
choices = colnames(iris)[1:4],
selected = colnames(iris)[1:4],
options = list(
`actions-box` = TRUE,
`selected-text-format` = paste0("count > ", length(colnames(iris)) - 1),
`count-selected-text` = "Alle",
liveSearch = TRUE,
liveSearchPlaceholder = TRUE
),
# build buttons for collective selection
multiple = TRUE
)
),
wellPanel(h4("Selected columns"), tableOutput("raw_data1")),
wellPanel(h4("Processed selected columns"), tableOutput("mean_data1"))
),
tabPanel(
title = "Table 2",
value = "tab2",
wellPanel(
pickerInput(
width = "75%",
inputId = "pick_col2",
label = "Select the columns of table 1 you wish to display:",
choices = colnames(mtcars),
selected = colnames(mtcars),
options = list(
`actions-box` = TRUE,
`selected-text-format` = paste0("count > ", length(colnames(mtcars)) - 1),
`count-selected-text` = "Alle",
liveSearch = TRUE,
liveSearchPlaceholder = TRUE
),
# build buttons for collective selection
multiple = TRUE
)
),
wellPanel(h4("Selected columns"), tableOutput("raw_data2")),
wellPanel(h4("Processed selected columns"), tableOutput("mean_data2"))
)
))

server <- function(input, output) {
# show the selected columns (plus the grouping variable)
output$raw_data1 <- renderTable({
iris %>% select(Species, input$pick_col1) %>%
group_by(Species) %>%
top_n(n = 2)
})

# show the processed columns
output$mean_data1 <- renderTable({
iris %>% select(Species, input$pick_col1) %>%
group_by(Species) %>%
summarise_all(.funs = list(cleanup))
})

# show the selected columns (plus the grouping variable)
output$raw_data2 <- renderTable({
mtcars %>% mutate("Car" = rownames(.)) %>%
select(Car, input$pick_col2) %>%
group_by(cyl) %>%
top_n(n = 2)
})

# show the processed columns
output$mean_data2 <- renderTable({
mtcars %>% mutate("Car" = rownames(.)) %>%
select(Car, input$pick_col2) %>%
group_by(cyl) %>%
summarise_all(.funs = list(cleanup))
})

}
shinyApp(ui, server)

**EDIT 2: same table in both tabs, same reactives that process the table, but they respond to different inputs based on the active tab: **

library(shiny)
library(shinyWidgets)
library(dplyr)

cleanup <- function(x) {
mean(x, na.rm = TRUE)
}

ui <- basicPage(tabsetPanel(
id = "tabs",
tabPanel(
title = "Table 1",
value = "tab1",
wellPanel(
pickerInput(
width = "75%",
inputId = "pick_col1",
label = "Select the columns of table 1 you wish to display:",
choices = colnames(iris)[1:4],
selected = colnames(iris)[1:4],
options = list(
`actions-box` = TRUE,
`selected-text-format` = paste0("count > ", length(colnames(iris)) - 1),
`count-selected-text` = "Alle",
liveSearch = TRUE,
liveSearchPlaceholder = TRUE
),
# build buttons for collective selection
multiple = TRUE
)
),
wellPanel(h4("Selected columns"), tableOutput("raw_data1")),
wellPanel(h4("Processed selected columns"), tableOutput("mean_data1"))
),
tabPanel(
title = "Table 2",
value = "tab2",
wellPanel(
pickerInput(
width = "75%",
inputId = "pick_col2",
label = "Select the columns of table 1 you wish to display:",
choices = colnames(iris)[1:4],
selected = colnames(iris)[1:4],
options = list(
`actions-box` = TRUE,
`selected-text-format` = paste0("count > ", length(colnames(iris)) - 1),
`count-selected-text` = "Alle",
liveSearch = TRUE,
liveSearchPlaceholder = TRUE
),
# build buttons for collective selection
multiple = TRUE
)
),
wellPanel(h4("Selected columns"), tableOutput("raw_data2")),
wellPanel(h4("Processed selected columns"), tableOutput("mean_data2"))
)
))

server <- function(input, output) {

# decide what to render based on the selected tab
respond_to_tab <- reactive({
if (input$tabs == "tab1") {
selected_columns <- input$pick_col1
} else {
selected_columns <- input$pick_col2
}
return(selected_columns)
})

raw_data <- reactive({
iris %>% select(Species, respond_to_tab()) %>%
group_by(Species) %>%
top_n(n = 2)
})

mean_data <- reactive({
iris %>% select(Species, respond_to_tab()) %>%
group_by(Species) %>%
summarise_all(.funs = list(cleanup))
})

# show the selected columns (plus the grouping variable)
output$raw_data1 <- renderTable({
raw_data()
})

# show the processed columns
output$mean_data1 <- renderTable({
mean_data()
})

# show the selected columns (plus the grouping variable)
output$raw_data2 <- renderTable({
raw_data()
})

# show the processed columns
output$mean_data2 <- renderTable({
mean_data()
})

}
shinyApp(ui, server)

EDIT 3: pickers rendered through renderUI dependent on tables selected by user. Otherwise works as EDIT 2. Note also some new packages are loaded.

library(shiny)
library(shinyWidgets)
library(dplyr)
library(stringr)
library(readxl)
library(readr)

cleanup <- function(x) {
mean(x, na.rm = TRUE)
}

ui <- basicPage(tabsetPanel(
id = "tabs",
tabPanel(
title = "File input",
value = "input",
fileInput(
"selection",
"Upload Files:",
multiple = T,
accept = c(
".xlsx",
".xls",
"text/csv",
"text/comma-separated-values, text/plain",
".csv"
)
)
),
tabPanel(
title = "Table 1",
value = "tab1",
uiOutput("picker1"),
wellPanel(h4("Selected columns"), tableOutput("raw_data1")),
wellPanel(h4("Processed selected columns"), tableOutput("mean_data1"))
),
tabPanel(
title = "Table 2",
value = "tab2",
uiOutput("picker2"),
wellPanel(h4("Selected columns"), tableOutput("raw_data2")),
wellPanel(h4("Processed selected columns"), tableOutput("mean_data2"))
)
))

server <- function(input, output) {

# handle the file import
read_input_file <- function(filepath) {
if (str_detect(filepath, regex(".csv$"))) {
out <- read_csv(filepath)
}

if (str_detect(filepath, regex(".xls$|.xlsx$"))) {
out <- read_excel(filepath)
}
return(out)
}

file1 <- reactive({
read_input_file(input$selection$datapath[1])
})

file2 <- reactive({
read_input_file(input$selection$datapath[2])
})

# pickers reactive to user input file
output$picker1 <- renderUI({
wellPanel(
pickerInput(
width = "75%",
inputId = "pick_col1",
label = "Select the columns of table 1 you wish to display:",
# still using iris (loaded from file), so 1:4 makes sense for the rest of the app logic
choices = colnames(file1())[1:4],
selected = colnames(file1())[1:4],
options = list(
`actions-box` = TRUE,
`selected-text-format` = paste0("count > ", length(colnames(iris)) - 1),
`count-selected-text` = "Alle",
liveSearch = TRUE,
liveSearchPlaceholder = TRUE
),
# build buttons for collective selection
multiple = TRUE
)
)
})

output$picker2 <- renderUI({
wellPanel(
pickerInput(
width = "75%",
inputId = "pick_col2",
label = "Select the columns of table 1 you wish to display:",
choices = colnames(file2())[1:4],
selected = colnames(file2())[1:4],
options = list(
`actions-box` = TRUE,
`selected-text-format` = paste0("count > ", length(colnames(iris)) - 1),
`count-selected-text` = "Alle",
liveSearch = TRUE,
liveSearchPlaceholder = TRUE
),
# build buttons for collective selection
multiple = TRUE
)
)
})

# decide what to render based on the selected tab
respond_to_tab <- reactive({
if (input$tabs == "tab1") {
selected_columns <- input$pick_col1
} else {
selected_columns <- input$pick_col2
}
return(selected_columns)
})

raw_data <- reactive({
iris %>% select(Species, respond_to_tab()) %>%
group_by(Species) %>%
top_n(n = 2)
})

mean_data <- reactive({
iris %>% select(Species, respond_to_tab()) %>%
group_by(Species) %>%
summarise_all(.funs = list(cleanup))
})

# show the selected columns (plus the grouping variable)
output$raw_data1 <- renderTable({
raw_data()
})

# show the processed columns
output$mean_data1 <- renderTable({
mean_data()
})

# show the selected columns (plus the grouping variable)
output$raw_data2 <- renderTable({
raw_data()
})

# show the processed columns
output$mean_data2 <- renderTable({
mean_data()
})

}
shinyApp(ui, server)

Another EDIT. Aside from the fixes related to iris, this code has another reactive to deal with which dataset to process based on the active tab.

library(shiny)
library(shinyWidgets)
library(dplyr)
library(stringr)
library(readxl)
library(readr)

# not used in this version
# it depends on the loaded datasets...
# need to define the function based on the expected input

cleanup <- function(x) {
mean(x, na.rm = TRUE)
}

ui <- basicPage(tabsetPanel(
id = "tabs",
tabPanel(
title = "File input",
value = "input",
fileInput(
"selection",
"Upload Files:",
multiple = T,
accept = c(
".xlsx",
".xls",
"text/csv",
"text/comma-separated-values, text/plain",
".csv"
)
)
),
tabPanel(
title = "Table 1",
value = "tab1",
uiOutput("picker1"),
wellPanel(h4("Selected columns"), tableOutput("raw_data1")),
wellPanel(h4("Processed selected columns"), tableOutput("mean_data1"))
),
tabPanel(
title = "Table 2",
value = "tab2",
uiOutput("picker2"),
wellPanel(h4("Selected columns"), tableOutput("raw_data2")),
wellPanel(h4("Processed selected columns"), tableOutput("mean_data2"))
)
))

server <- function(input, output) {

# handle the file import
read_input_file <- function(filepath) {
if (str_detect(filepath, regex(".csv$"))) {
out <- read_csv(filepath)
}

if (str_detect(filepath, regex(".xls$|.xlsx$"))) {
out <- read_excel(filepath)
}
return(out)
}

file1 <- reactive({
read_input_file(input$selection$datapath[1])
})

file2 <- reactive({
read_input_file(input$selection$datapath[2])
})

# pickers reactive to user input file
output$picker1 <- renderUI({
wellPanel(
pickerInput(
width = "75%",
inputId = "pick_col1",
label = "Select the columns of table 1 you wish to display:",
# still using iris (loaded from file), so 1:4 makes sense for the rest of the app logic
choices = colnames(file1()),
selected = colnames(file1()),
options = list(
`actions-box` = TRUE,
`selected-text-format` = paste0("count > ", length(colnames(file1())) - 1),
`count-selected-text` = "Alle",
liveSearch = TRUE,
liveSearchPlaceholder = TRUE
),
# build buttons for collective selection
multiple = TRUE
)
)
})

output$picker2 <- renderUI({
wellPanel(
pickerInput(
width = "75%",
inputId = "pick_col2",
label = "Select the columns of table 1 you wish to display:",
choices = colnames(file2()),
selected = colnames(file2()),
options = list(
`actions-box` = TRUE,
`selected-text-format` = paste0("count > ", length(colnames(file2())) - 1),
`count-selected-text` = "Alle",
liveSearch = TRUE,
liveSearchPlaceholder = TRUE
),
# build buttons for collective selection
multiple = TRUE
)
)
})

# decide what columns to render based on the selected tab
respond_to_tab <- reactive({
if (input$tabs == "tab1") {
selected_columns <- input$pick_col1
} else {
selected_columns <- input$pick_col2
}
return(selected_columns)
})
# decide what table to work with based on the selected tab
respond_to_tab_data <- reactive({
if (input$tabs == "tab1") {
x <- file1()
} else {
x <- file2()
}
return(x)
})


Related Topics



Leave a reply



Submit