全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
23997 8
2013-08-18
RT。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2013-8-19 11:12:30
R的这个类型确实有些不好理解。
我的粗略的理解:
mode是R存诸对象的类型, class 的概念是沿袭面向对象编程的概念而来,是一个更抽象的概念。typeof 和mode 相似,但是好像比mode分得更精细。

从精细度上说,typeof>mode>class.

对R了解不多,不一定对。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-8-19 18:47:37
还是感谢版主大人了!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-8-20 22:58:38
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




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-8-20 22:59:08

我这里用个因子例子来说明,希望能讲清楚
> 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
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-8-21 08:22:29
zhengbo8 发表于 2013-8-19 18:47
还是感谢版主大人了!
都开始折腾R了。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群