How to construct a new s3 class?



How to construct a new s3 class?..

Answer / Maneesh Singh Rajput

To create a new S3 class in R, you need to define a constructor function with the name `create.myclass()`, and set the class attribute of an object created with this function: `setClass("myClass", contains = list(myAttribute = "character"))`. You can then create objects of this class using `myObject <- create.myClass(myAttribute = "value")`.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More R Programming Interview Questions

List the functions available in “dplyr” package?

1 Answers  


What is R lists?

1 Answers  


What are useful s3 method functions?

1 Answers  


What are the data types in r on which binary operators can be applied?

1 Answers  


What is principal component analysis and how can you create a pca model in r?

1 Answers  


Compare R with other technologies.

1 Answers  


how to import data into R?

1 Answers  


What is object-oriented programming in r?

1 Answers  


Compare r and python?

1 Answers  


What are programming features of R?

1 Answers  


What is r programming?

1 Answers  


How would you fit a linear model over a scatter-plot?

1 Answers  


Categories