Remssssss
Remssssss

Reputation: 89

R - Creating a class with a list attribute

I am pretty new using R in an advanced way...so apologize for futile questions! I want to create a object of class S4, defined by 3 slots. Thing is that I can't manage to create these attributes as a list. Here is my code :

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"))

and the error I get :

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

Could you please explain how creating an object with list plot? Thx!

Upvotes: 1

Views: 795

Answers (1)

Karl Forner
Karl Forner

Reputation: 4414

try this:

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

Upvotes: 3

Related Questions