I'm writing a set of R functions that will be up online, publicly available, so I'd like to do a clean job here...for the first time.
Basically there is a function f
that receives a dataframe and computes five real-valued numbers, call them x1
,x2
,x3
,x4
and x5
. Then, one can call a set of other functions g1
,g2
,g3
that, based on those five numbers, compute some other things. So I'd like those 5 numbers to be integrated in a single object, so to speak. Maybe even let those g_i
functions be part of that object, like a method, or link to the original data that generated them.
Right now the f
function just returns a vector with named entries, but I'd like it to be clean, have it's own print
function, etc.
What is the best way to do this? I'm thinking of something similar to the lm
function and the model objects. Are those R objects? I've never done anything like this in R, so any pointer will be much appreciated.