Reputation: 1091
For example, I see the XTS object created using a package of same name. If I wanted to create for example a class of "Interest Rate Swap", would that be possible? How? I found an example using lambd.r here http://www.r-bloggers.com/pricing-interest-rate-swaps-with-lambda-r/ however that seems having to leverage functional programming. I searched for "constructor" in the R-Book, but nothing there.
Upvotes: 2
Views: 3379
Reputation: 4993
You can use the setClass
method. It, and the parameters, are described pretty well here:
Site to Create an Object Class
It allows you to set all of the parameters you would want to use to define a class and create objects for a package (like a SpatialPolygon from Leaflet). You can start with the basics found there, but you will likely want to read one of the books on creating packages if you intend to create a series of intertwined methods to work on a specific class of object you create.
Upvotes: 5