Hello everyone! I have an opinion question please. If I?m writing a new package, would you recommend using S3 or S4 structure, please? I know I will get lots of opinions, but that?s fine. Thanks, Erin Erin Hodgess, PhD mailto: erinm.hodgess at gmail.com [[alternative HTML version deleted]]
My *opinion*: 1. As it stands, this "opinion survey" seems pretty useless; 2. It *might* be more useful if you explained what the package will do, who it's intended users are, etc. -- Bert "An educated person is one who can entertain new ideas, entertain others, and entertain herself." On Mon, Apr 7, 2025 at 10:36?AM Erin Hodgess <erinm.hodgess at gmail.com> wrote:> Hello everyone! > > I have an opinion question please. If I?m writing a new package, would you > recommend using S3 or S4 structure, please? > > I know I will get lots of opinions, but that?s fine. > > Thanks, > Erin > > > Erin Hodgess, PhD > mailto: erinm.hodgess at gmail.com > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
My opinion is that you should use S3 unless you absolutely need some syntactic sugar only offered by some other object system. Note that in a majority of cases you want to transform one standard data structure to another... tibble to tibble is the fashion for dplyr... and functions can often do what you want just fine except that they sometimes end up needing a lot of arguments that you want to refer to in many places. You can often make a class that holds those arguments so they can be re-used and where the class has methods to do the desired transformation (s) where the bulk data remains handled as arguments and return values rather than as data in the object itself. The lm class in base R uses a "constructor computes and methods retrieve results" approach... which isn't quite as flexible as a transformer approach but still hides the gory details. My reason for giving these examples is that the functional/OO approach expresses problems quite cleanly using S3... and you don't have to pay the performance/hoop-jumping/extra dependencies that you need for R5 or R7. That is, you should think carefully about whether you really need whatever features that more advanced OO system offers... and then you will know the answer to the question you posed for yourself. On April 7, 2025 10:35:44 AM PDT, Erin Hodgess <erinm.hodgess at gmail.com> wrote:>Hello everyone! > >I have an opinion question please. If I?m writing a new package, would you >recommend using S3 or S4 structure, please? > >I know I will get lots of opinions, but that?s fine. > >Thanks, >Erin > > >Erin Hodgess, PhD >mailto: erinm.hodgess at gmail.com > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide https://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.-- Sent from my phone. Please excuse my brevity.
On Mon, 7 Apr 2025 11:35:44 -0600 Erin Hodgess <erinm.hodgess at gmail.com> wrote:> Hello everyone! > > I have an opinion question please. If I?m writing a new package, > would you recommend using S3 or S4 structure, please? > > I know I will get lots of opinions, but that?s fine. > > Thanks, > ErinSee fortunes::fortune(121). cheers, Rolf -- Honorary Research Fellow Department of Statistics University of Auckland Stats. Dep't. (secretaries) phone: +64-9-373-7599 ext. 89622 Home phone: +64-9-480-4619
?s 18:35 de 07/04/2025, Erin Hodgess escreveu:> Hello everyone! > > I have an opinion question please. If I?m writing a new package, would you > recommend using S3 or S4 structure, please? > > I know I will get lots of opinions, but that?s fine. > > Thanks, > Erin > > > Erin Hodgess, PhD > mailto: erinm.hodgess at gmail.com > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.Hello, I prefer S3's simplicity. It's easy to program and there are lots of packages using it, including, for time series, base class ts and its functions, zoo, xts, etc. If you want a good introduction to creating a package using S4, read package Brobdingnag [1] vignette. vignette("S4_brob", package = "Brobdingnag") [1] https://CRAN.R-project.org/package=Brobdingnag Hope this helps, Rui Barradas -- Este e-mail foi analisado pelo software antiv?rus AVG para verificar a presen?a de v?rus. www.avg.com