[R] An opinion question, please
Erin Hodgess
er|nm@hodge@@ @end|ng |rom gm@||@com
Tue Apr 8 17:47:18 CEST 2025
I was thinking about xts and zoo as well!
Thanks!
Erin Hodgess, PhD
mailto: erinm.hodgess using gmail.com
On Tue, Apr 8, 2025 at 12:39 AM Eric Berger <ericjberger using gmail.com> wrote:
> If you are writing a new package I don't see why you should restrict
> yourself to S3 or S4 classes.
> Your "new package" can certainly build on other packages. (Why not?)
> As I wrote in my previous email, if you are dealing with time series
> you might want to consider appropriate classes already defined in
> other packages, such as those obtained via
>
> library(fpp3)
>
> In my work, I deal with many financial time series. I highly recommend
> the xts package which is a subclass of the zoo class. The zoo class is
> an S3 time series class built on matrix.
> The xts class is "designed for fast, consistent time-based indexing,
> ideal for financial time series" (quoting ChatGPT here).
>
> The xts package is maintained by Joshua Ulrich who is extremely active
> and helpful in responding to questions about xts in the R-help lists.
>
> HTH,
> Eric
>
> On Tue, Apr 8, 2025 at 2:24 AM Erin Hodgess <erinm.hodgess using gmail.com>
> wrote:
> >
> > We can have different frequencies of data, including Business day data
> and
> > daily data as our outputs.
> >
> > Both of those will start on Monday.
> >
> > Erin Hodgess, PhD
> > mailto: erinm.hodgess using gmail.com
> >
> >
> > On Mon, Apr 7, 2025 at 4:57 PM CALUM POLWART <polc1410 using gmail.com> wrote:
> >
> > > Clearly something has gone terribly wrong. Everyone is saying use S3.
> This
> > > is an online discussion... So someone needs to support S4.
> > >
> > > Which frighteningly seems to be me! I'd caution you now... I first
> used an
> > > S4 object about two weeks ago and still have no real idea if they do
> what I
> > > think they do!
> > >
> > > My understanding is S4 objects can hold the source data and the
> commands
> > > to make the result data. Which means in terms of reproduction of
> results
> > > this may be better...
> > >
> > > ...I'm not at all sure I know what you want to do with your data. But
> > > assuming you started with a time series of daily maximum temperature, I
> > > think with an S4 object the daily maximum can be saved, plus the week,
> > > month, season, year etc.
> > >
> > > If week could begin on a Monday or a Sunday, the info that is used to
> > > decide is stored for reference.
> > >
> > > S4 can enforce data types.
> > >
> > > On Mon, 7 Apr 2025, 22:40 Jeff Newmiller via R-help, <
> r-help using r-project.org>
> > > wrote:
> > >
> > >> 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 using 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 using gmail.com
> > >> >
> > >> > [[alternative HTML version deleted]]
> > >> >
> > >> >______________________________________________
> > >> >R-help using 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.
> > >>
> > >> ______________________________________________
> > >> R-help using 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]]
> >
> > ______________________________________________
> > R-help using 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]]
More information about the R-help
mailing list