Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How to change the column names 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 <- data.frame(ID=1:5,Salry=c(10000,30000,22000,27000,18000))
> df
ID Salry
1 1 10000
2 2 30000
3 3 22000
4 4 27000
5 5 18000
> colnames(df)<-c("EmployeeID","Salary")
> df
EmployeeID Salary
1 1 10000
2 2 30000
3 3 22000
4 4 27000
5 5 18000
> rownames(df)<-c("001","025","019","102","089")
df
EmployeeID Salary
001 1 10000
025 2 30000
019 3 22000
102 4 27000
089 5 18000 Advertisements
