Print the Value of an Object in R Programming – identity() Function

identity() function in R Language is used to print the value of the object which is passed to it as argument.

Syntax: identity(x)

Parameters:
x: An Object

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to print
# the value of an object
  
# Creating a vector
x <- c(1, 2, 3, 4)
  
# Creating a list
list1 <- list(letters[1:6]) 
  
# Calling the identity function
identity(x)
identity(list1)

chevron_right


Output:

[1] 1 2 3 4
[[1]]
[1] "a" "b" "c" "d" "e" "f"

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to print
# the value of an object
  
# Calling predefined data frame
x1 <- BOD
  
# Creating a matrix
mat <- matrix(c(1:9), 3, 3, byrow = T)
  
# Calling the identity() Function
identity(x1)
identity(mat)

chevron_right


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] [, 2] [, 3]
[1, ]    1    2    3
[2, ]    4    5    6
[3, ]    7    8    9
My Personal Notes arrow_drop_up

Recommended Posts:


Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.