Change Column and Row Names of a Data Frame in R



We can colnames function to change the column names and rownames function to change the row names.

Example

> df  df
ID Salry
1 1 10000
2 2 30000
3 3 22000
4 4 27000
5 5 18000
> colnames(df) df
EmployeeID Salary
1 1 10000
2 2 30000
3 3 22000
4 4 27000
5 5 18000
> rownames(df)
Updated on: 2020-07-06T12:56:42+05:30

535 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements