Get or Set names of Elements of an Object in R Programming - names() Function Last Updated : 05 Jun, 2020 Comments Improve Suggest changes Like Article Like Report names() function in R Language is used to get or set the name of an Object. This function takes object i.e. vector, matrix or data frame as argument along with the value that is to be assigned as name to the object. The length of the value vector passed must be exactly equal to the length of the object to be named. Syntax: names(x) <- value Parameters: x: Object i.e. vector, matrix, data frame, etc. value: Names to be assigned to x Example 1: Python3 1== # R program to assign name to an object # Creating a vector x <- c(1, 2, 3, 4, 5) # Assigning names using names() function names(x) <- c("gfg1", "gfg2", "gfg3", "gfg4", "gfg5") # Printing name vector that is assigned names(x) # Printing updated vector print(x) Output: [1] "gfg1" "gfg2" "gfg3" "gfg4" "gfg5" gfg1 gfg2 gfg3 gfg4 gfg5 1 2 3 4 5 Example 2: Python3 1== # R program to get names of an Object # Importing Library library(datasets) # Importing dataset head(airquality) # Calling names() function to get names names(airquality) Output: Ozone Solar.R Wind Temp Month Day 1 41 190 7.4 67 5 1 2 36 118 8.0 72 5 2 3 12 149 12.6 74 5 3 4 18 313 11.5 62 5 4 5 NA NA 14.3 56 5 5 6 28 NA 14.9 66 5 6 [1] "Ozone" "Solar.R" "Wind" "Temp" "Month" "Day" Comment More infoAdvertise with us Next Article Get or Set names of Elements of an Object in R Programming - names() Function N nidhi_biet Follow Improve Article Tags : R Language R DataFrame-Function R Vector-Function R Object-Function R Matrix-Function R List-Function +2 More Similar Reads 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 Coercing the Argument to a Name in R Programming - as.name() Function as.name() function in R Language is used to coerce the argument to a name. The as.name() and as.symbol() functions are identical. Syntax: as.name(x) Parameters: x: Object to be coerced Example 1: Python3 # R program to illustrate # as.name() function # Calling the as.name() function to # coerce the 1 min read Display the internal Structure of an Object in R Programming - str() Function str() function in R Language is used for compactly displaying the internal structure of a R object. It can display even the internal structure of large lists which are nested. It provides one liner output for the basic R objects letting the user know about the object and its constituents. It can be 3 min read Make Elements of a Vector Unique in R Programming - make.unique() Function make.unique() function in R Language is used to return elements of a vector with unique names by appending sequence numbers to duplicates. Syntax: make.unique(names, sep)Parameters: names: Character vector with duplicate names sep: Separator to be used  Example 1: Python3 # R program to make uniqu 1 min read Convert an Object to List in R Programming - as.list() Function as.list() function in R Programming Language is used to convert an object to a list. These objects can be Vectors, Matrices, Factors, and dataframes. Syntax: as.list(object) Parameters: object: Vector, Matrix, factor, or data frame R - as.list() Function ExampleExample 1: Converting Vector to list 2 min read Like