在 R 编程中获取不同数据类型的类型 - typeof()函数
R 语言中的typeof()
函数用于返回用作参数的数据类型。
Syntax: typeof(x)
Parameters:
x: specified data
示例 1:
# R program to illustrate
# typeof function
# Specifying "Biochemical oxygen demand"
# data set
x <- BOD
x
# Calling typeof() function
typeof(x)
输出:
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] "list"
示例 2:
# R program to illustrate
# typeof function
# Calling typeof() function
# over different types of data
typeof(2)
typeof(2.8)
typeof("3")
typeof("gfg")
typeof(1 + 2i)
输出:
[1] "double"
[1] "double"
[1] "character"
[1] "character"
[1] "complex"