【问题标题】:R - Creating a class with a list attributeR - 创建一个具有列表属性的类
【发布时间】:2014-05-16 16:28:41
【问题描述】:

我是一个以高级方式使用 R 的新手……所以对于无用的问题深表歉意! 我想创建一个由 3 个插槽定义的 S4 类对象。问题是我无法将这些属性创建为列表。这是我的代码:

test<-setClass("dblist",representation(df.list="list", df.para="list",df.coups="list"))
new("dblist",representation(df.list="list", df.para="list",df.coups="list"))

我得到的错误:

Error in initialize(value, ...) : cannot use object of class “list” in new():  class   
“dblistpgn” does not extend that class

您能否解释一下如何使用列表图创建对象? 谢谢!

【问题讨论】:

    标签: r list class s4 slots


    【解决方案1】:

    试试这个:

    new("dblist", df.list = list(), df.para = list(), df.coups = list())
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多