Convert Character String to Variable Name in R Last Updated : 03 May, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article we will discuss how to convert a character string to the variable name in the R programming language i.e. we are going to assign the character string to the variable as the variable name Method 1: Using assign() function We can assign character string to variable name by using assign() function. We simply have to pass the name of the variable and the value to the function. Syntax: assign("variable_name",value) Parameter: variable_name is the name of the valuevalue is the variable. Example: R # assign variable name to 3 value assign("variable_name",3) # print variable name print(variable_name) Output: [1] 3 We can also create a vector with a group of variables and assign a single variable name. Example: R # create 5 variables at a time assign("vector1",c(1,2,3,4,5)) # print variable name print(vector1) Output: [1] 1 2 3 4 5 the time complexity of creating five variables using assign() and printing the variable name using print() is O(1) + O(1) = O(1). The auxiliary space complexity of creating the variables using assign() is O(n) Method 2: Using do.call() function This function allows you to call any R function. It allows using a list to hold the arguments of the function along with passing of single arguments. Syntax: do.call("=",list("variable_name", value)) Where "=" is an assign operator The variable name is the named assigned to the value and value is the input value/variable. Example: R do.call("=",list("a", 1)) print(a) Output: [1] 1 Example: R do.call("=",list("a", c(1,2,3,4,5))) print(a) Output: [1] 1 2 3 4 5 Comment More infoAdvertise with us Next Article Convert Character String to Variable Name in R P pulamolusaimohan Follow Improve Article Tags : R Language R Programs R-strings Similar Reads How to Convert Character to Numeric in R? In this article, we will discuss how to convert characters to numeric in R Programming Language. We can convert to numeric by using as.numeric() function. Syntax: as.numeric(character) where, character is an character vector Example: R # create a vector with 5 characters data = c('1', '2', '3', '4', 1 min read Concatenate Vector of Character Strings in R In this article, we will discuss how to concatenate the strings present in two or more vectors in R Programming Language. Discussed below are various methods of doing so. Method 1: Using paste() paste() function is used to combine strings present in vectors passed to it  an argument. Syntax: paste( 4 min read Extract Numbers from Character String Vector in R In this article, we are going to see how to extract Numbers from Character String Vector in R Programming Language. There are different approaches to extract numbers from character string vectors using some in-built functions. It can be done in the following ways:Using the gsub() functionUsing the g 2 min read Count Number of Characters in String in R In this article, we are going to see how to get the number of characters in a string in R Programming Language. The number of characters in a string refers to the length of the string.Examples:Input: GeeksforgeeksOutput: 13Explanation: Total 13 characters in the given string.Input: Hello worldOutput 2 min read Convert Character Matrix to Numeric Matrix in R In this article, we are going to see how to convert a given character matrix to numeric in R Programming Language. Converting the Character Matrix to Numeric Matrix we will use as.numeric() & matrix() Functions. Functions Usedas.numeric() function: This function is used to convert a given column 3 min read Like