mode():模式,常见的有"logical", "integer", "double", "complex", "raw", "character", "list", "expression", "name", "symbol" and "function".
class():类,In R every 'object' has a mode and a class.
Modes have the same set of names as types (see
typeof) except that
- types "integer" and "double" are returned as "numeric".
- types "special" and "builtin" are returned as "function".
- type "symbol" is called mode "name".
- type "language" is returned as "(" or "call".
from:?mode()
也可以参考:http://stackoverflow.com/questio ... -and-class-and-type
我这里用个因子例子来说明,希望能讲清楚
> gl(2,5) #新建一个因子
[1] 1 1 1 1 1 2 2 2 2 2
Levels: 1 2
> class(gl(2,5)) #查看变量的类,显示为因子;
[1] "factor"
> mode(gl(2,5)) #查看数据大类,显示为数值型;
[1] "numeric"
> typeof(gl(2,5)) #查看数据细类,显示为整数型;
[1] "integer"
来自:http://f.dataguru.cn/thread-99785-1-1.html
|