Delete/Add columns of data frames interactively as tables in Shiny R

shiny
datatable

#1

I want to display interactive data frames as tables in R, where each data frame is displayed in a separate tab, and the user can select which columns to display using a checkbox side panel for each. I am using the code below, but it has the following problems:
(1) The user can select/unselect columns for df1 only. Even if you unselect columns for df2/3, it is still displayed.
(2) For all data frames, the columns of the data frame are replicated twice at the end of each table.

Any help to fix those two issues will be appreciated!

CODE:

#Read data frames from txt files
df1 = as.data.frame(fread (myfile1.txt))
df2 = as.data.frame(fread (myfile2.txt))
df3 = as.data.frame(fread (myfile3.txt))
#Load libraries
library(data.table)
library(plotly)
library(shiny)
library(ggplot2)
library(extrafont)
library(DT)

#UI Function
ui <- fluidPage(
  title = "Examples of DataTables",
  sidebarLayout(
    sidebarPanel(
      conditionalPanel(
        'input.dataset === "df1"',
        helpText("Click the column header to sort a column."),
        checkboxGroupInput("show_vars", "Columns in df1 to show:",
                           names(df1), selected = names(df1))
      ),
      conditionalPanel(
        'input.dataset === "df2"',
        helpText("Click the column header to sort a column."),
        checkboxGroupInput("show_vars", "Columns in df2 to show:",
                           names(df2), selected = names(df2))
      ),
      conditionalPanel(
        'input.dataset === "df3"',
        helpText("Click the column header to sort a column."),
        checkboxGroupInput("show_vars", "Columns in df3 to show:",
                           names(df3), selected = names(df3))
      )
    ),
    mainPanel(
      tabsetPanel(
        id = 'dataset',
        tabPanel("df1", DT::dataTableOutput("mytable1")),
        tabPanel("df2", DT::dataTableOutput("mytable2")),
        tabPanel("df3", DT::dataTableOutput("mytable3"))
      )
    ),    
  )
)
#Server Function
server <- function(input, output) {
  
  #df1
  df1_ = m0[sample(nrow(df1), 1000), ]
  output$mytable1 <- DT::renderDataTable({
    DT::datatable(df1_[, input$show_vars, drop = FALSE])
  })
  
  #df2
  df2_ = df2[sample(nrow(df2), 1000), ]
  output$mytable2 <- DT::renderDataTable({
    DT::datatable(df2_[, input$show_vars, drop = FALSE])
  })
  
  # df3
  df3_ = df3[sample(nrow(df3), 1000), ]
   output$mytable3 <- DT::renderDataTable({
    DT::datatable(df3_[, input$show_vars, drop = FALSE])
  })
}

#Display
shinyApp(ui, server)