Rename Columns of a Data Frame in R Programming - rename() Function Last Updated : 02 May, 2025 Comments Improve Suggest changes Like Article Like Report The rename() function in R Programming Language is used to rename the column names of a data frame, based on the older names.Syntax: rename(x, names) Parameters:x: Data frame names: Old name and new name 1. Rename a Data Frame using rename function in RWe are using the plyr package to rename the columns of a data frame. After creating a data frame with columns row1, row2, and row3, we use the rename() function to change these column names to one, two, and three. Since rename() returns a modified copy of the data frame, we assign it back to the original variable, df, and then print the modified data frame. R install.packages("plyr") library(plyr) df<-data.frame(row1 = 0:2, row2 = 3:5, row3 = 6:8) print("Original Data Frame") print(df) print("Modified Data Frame") rename(df, c("row1"="one", "row2"="two", "row3"="three")) Output:Using rename() Function2. Modify names of a data frame using rename functionWe are using the plyr package to rename the columns of a data frame. After creating a data frame with columns col1, col2, and col3, we use the rename() function to change these column names to Name, Language, and Age. The modified data frame is returned with the updated column names. R library(plyr) df = data.frame( "col1" = c("abc", "def", "ghi"), "col2" = c("R", "Python", "Java"), "col3" = c(22, 25, 45) ) return(df) rename(df, c("col1" = "Name", "col2" = "Language", "col3" = "Age")) Output:Using rename() Function3. Change Multiple Columns using rename function in RWe are using the rename() function from the plyr package to rename the columns of the iris dataset. After loading the iris data, we change the column names Sepal.Length, Sepal.Width, Petal.Length, and Petal.Width to iris1, iris2, iris3, and iris4, respectively. The modified dataset is then returned with the updated column names. R data(iris) head(iris) rename_columns<-rename(iris,c('Sepal.Length'='iris1', 'Sepal.Width'='iris2', 'Petal.Length'='iris3', 'Petal.Width'='iris4')) head(rename_columns) Output:Using rename() FunctionIn this article, we explored how to rename columns in a data frame in R using the rename() function from the plyr package Comment More infoAdvertise with us Next Article Rename Columns of a Data Frame in R Programming - rename() Function N nidhi_biet Follow Improve Article Tags : R Language R DataFrame-Function Similar Reads Condense Column Values of a Data Frame in R Programming - summarise() Function summarise() function in R Language is used to condense various values of column of a data frame to one value. Syntax: summarise(x, expr) Parameters: x: Data Frame expr: Operation to condense data Example 1: Python3 1== # R program to condense data # of a data frame # Loading library library(dplyr) # 1 min read Reordering of a Data Set in R Programming - arrange() Function arrange() function in R Language is used for reordering of table rows with the help of column names as expression passed to the function. Syntax: arrange(x, expr) Parameters: x: data set to be reordered expr: logical expression with column name Example 1: Python3 1== # R program to reorder a data se 1 min read Remove names or dimnames from an Object in R Programming - unname() Function unname() function in R Language is used to remove the names or dimnames from an Object. Syntax: unname(x) Parameters: x: Object Example 1: Python3 1== # R Program to remove names from an object # Creating a matrix A = matrix(c(1:9), 3, 3) # Naming rows rownames(A) = c("a", "b", 1 min read The Factor Issue in a DataFrame in R Programming DataFrames are generic data objects of R which are used to store the tabular data. Data frames are considered to be the most popular data objects in R programming because it is more comfortable to analyze the data in the tabular form. Data frames can also be taught as matrices where each column of a 4 min read Convert an Object to Data Frame in R Programming - as.data.frame() Function as.data.frame() function in R Programming Language is used to convert an object to data frame. These objects can be Vectors, Lists, Matrices, and Factors. Syntax: as.data.frame(object) Parameters:Â object: Vector, Matrix, factor, or data frameR - as.data.frame() Function ExampleExample 1: Basic exam 2 min read Naming Rows and Columns of a Matrix in R Programming - rownames() and colnames() Function rownames() function in R Language is used to set the names to rows of a matrix. Syntax: rownames(x) <- value Parameters: x: Matrix value: Vector of names to be set Example: Python3 1== # R program to provide a name # to rows of a Matrix # Creating a 3X3 Matrix A = matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 1 min read Convert a Data Frame into a Numeric Matrix in R Programming - data.matrix() Function data.matrix() function in R Language is used to create a matrix by converting all the values of a Data Frame into numeric mode and then binding them as a matrix. Syntax: data.matrix(df) Parameters: df: Data frame to be converted. Example 1: Python3 1== # R program to convert a data frame # into a nu 2 min read Modify values of a Data Frame in R Language - transform() Function transform() function in R Language is used to modify data. It converts the first argument to the data frame. This function is used to transform/modify the data frame in a quick and easy way. Syntax: transform(data, value) Parameters: data: Data Frame to be modified value: new modified value of data 2 min read Change more than one column name of a given DataFrame in R A data frame is a tabular structure with fixed dimensions, of each row as well as columns. It is a two-dimensional array-like object with numerical, character-based, or factor-type data. Each element belonging to the data frame is indexed by a unique combination of the row and column number respecti 4 min read Change column name of a given DataFrame in R A data frame is a tabular structure with fixed dimensions, of each rows as well as columns. It is a two-dimensional array like object with numerical, character based or factor-type data. Each element belonging to the data frame is indexed by a unique combination of the row and column number respecti 6 min read Like