Open In App

Remove names or dimnames from an Object in R Programming - unname() Function

Last Updated : 16 Jun, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
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", "c") 
   
# Naming columns 
colnames(A) = c("c", "d", "e") 
   
print(A) 

# Removing names using unname() function
unname(A)
Output:
  c d e
a 1 4 7
b 2 5 8
c 3 6 9
     [, 1] [, 2] [, 3]
[1, ]    1    4    7
[2, ]    2    5    8
[3, ]    3    6    9
Example 2: Python3 1==
# R Program to remove names from an object

# Calling pre-defined data set
BOD

# Removing names using unname() function
unname(BOD)
Output:
  Time demand
1    1    8.3
2    2   10.3
3    3   19.0
4    4   16.0
5    5   15.6
6    7   19.8
        
1 1  8.3
2 2 10.3
3 3 19.0
4 4 16.0
5 5 15.6
6 7 19.8

Next Article
Article Tags :

Similar Reads