Hello,
Here is my minimal reproducible example. I am currently restricted to 3.4.3 and some other constraints so I want a general replacement for as_name() as that is what I would have wanted to use but cannot under the circumstances. (The code below works).
#Basic example
library(shiny)
library(tidyverse)
library(rlang)
shinyApp(
ui = fluidPage(
sidebarLayout(
position = "left",
sidebarPanel(
uiOutput("df_merge_column_selection"),
textInput("new_label_postmerge", "New label:"),
actionButton("combine_columns", "Combine columns")
),
mainPanel(
tabPanel("1",
tableOutput("table"),
tableOutput("post"))
)
)
),
server = function(input, output) {
values <- reactiveValues(df_data = as.data.frame(NULL))
df_iris <- reactive({
temp <- iris
values$df_data <- temp
})
output$df_merge_column_selection <- renderUI({
varSelectInput("variable_merge",
"Columms to merge:",
values$df_data,
multiple = TRUE
)
})
observeEvent(input$combine_columns, {
req(input$new_label_postmerge)
temp <- values$df_data %>%
dplyr::rowwise() %>%
dplyr::mutate(!!as_name(input$new_label_postmerge) := sum(!!!input$variable_merge)) %>%
select(-c(!!!(input$variable_merge)))
values$df_data <- temp
})
output$table <- renderTable({df_iris()})
output$post <- renderTable({values$df_data})
}
)