Alternative to as_name() within Shiny

Hello,

Currently I have the below code in an application but the as_name() function is not accessible to me for a variety of reasons. What alternative can I use to coerce the input as a variable instead just as text without using as_name()?

dplyr::mutate(!!as_name(input$new_label_postmerge) := 

Using dplyr::sym should do the trick :

library(dplyr)
input <- list()
input$new_name <- "new_name"
mtcars %>%
               tibble::rownames_to_column(var = "cars_name") %>% 
               tibble::as_tibble() %>% 
               mutate( !!sym(input$new_name) := paste0("new_", cars_name))

Hello,

Thanks for the response. I'll create a reproducible example tonight and send. I don't have access to dplyr::sym either as it stands. I really need it as simple as possible.

Then you could use old reliable R base for this :

your_df[[input$new_label_postmerge]] <- the_new_variable_vector

With previous reproducible example :

library(dplyr)
                input <- list()
                input$new_name <- "new_name"
                mtcars <- mtcars %>%
                                tibble::rownames_to_column(var = "cars_name") %>%
                                tibble::as_tibble()
                mtcars[[input$new_name]] <- paste0("new_", mtcars$cars_name)
                mtcars

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})

  }
)