On Aug 31, 2012, at 5:57 AM, Ramiro Barrantes wrote: > Hello, > > I have again a "good practices"/programming theory question regarding > data.frames. > > One of the fundamental objects that I use is the data frame with a particular > set of columns that I would fill or get information from, and an entire > system would revolve around getting information from or putting information > to such data.frame. > > On a different OOP programming language I would be tempted to create a class > that would "wrap-around" that data.frame and create "getters" and "setters" > methods that would return whatever information I need. I started doing that > using S4. > > Does anyone have examples of packages that use that approach or any > suggestions? It just seems to me that a class/object would be a better idea > because it would create a single, hopefully well validated way to access > information and edit the fundamental data.frame object, which would be > helpful if there are several programmers on the team and/or if some of the > data.frame manipulations are not straightforward and are best left > encapsulated in a method of a class, and then have people use that method. I > would just like to know if there are reasons not do it that way and if there > are any examples of packages that use that approach and that I can learn from.
You could argue that the entire BioConductor project represents such an effort. It makes extensive use of S4 methods. I'm not a user so cannot readily point to examples of S4 functions that have set. and get. methods for particular sorts of dataframes, but I suspect you can pose the same question on the BioC mailing list and get a more informed answer. -- David Winsemius, MD Alameda, CA, USA ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.