美文网首页
2.3.3 attribute()和attr()函数

2.3.3 attribute()和attr()函数

作者: Andrew_bao | 来源:发表于2017-05-18 10:16 被阅读0次

    2.3.3 attribute()和attr()函数

    attribute(object)返回对象object的各种特殊属性组成列表,不包括属性mode和length.

    x<-c(apple=2.5,orange=2.1);x
    attributes(x)

    attr(object,name)存取对象object的名为name的属性。

    attr(x,"names")

    2.通过对其赋值改变属性值或者定义新的属性

    attr(x,"names")<-c("apple","grapes");x

    添加新的属性值

    attr(x,"type")<-"fruit";x
    attributes(x)

    2.3.4 对象class的属性

    这个在后续章节会用到。

    相关文章

      网友评论

          本文标题:2.3.3 attribute()和attr()函数

          本文链接:https://www.haomeiwen.com/subject/mffsxxtx.html