R语言 打印一个对象的值–ident()函数
R语言中的 identity() 函数用于打印作为参数传递给它的对象的值。
语法: identity(x)
参数:
x: 一个对象
例1 :
# 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)
输出
[1] 1 2 3 4
[[1]]
[1] "a" "b" "c" "d" "e" "f"
例2 :
# 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)
输出
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