[R] An opinion question, please

Ebert,Timothy Aaron tebert @end|ng |rom u||@edu
Tue Apr 8 15:28:10 CEST 2025


I would use the approach that is most commonly used by my potential user base unless I can define a clear set of reasons why I should do it differently. If users will be unable to see the difference, then the decision is entirely up to me based on ease of programming at all phases (writing, debug, maintenance), and in some cases execution speed.

You may be further limited based on other software that you either need or that you hope will need you. Use the approach that will make these interactions easier or program in such a way that your program is S3 S4 agnostic when it comes to interacting with others.

Most of your users will want to do their time series analysis and move on. They do not want a big fight about programming. Their goal will be ease of use, and utility.

My guess is you want S3 unless users will not see the difference. If users cannot interact with your code at the level where they need to know the difference between S3 and S4, then you choose the approach that makes your life easier in the long run.

Another consideration: Your documentation needs to be sufficient for users to learn your package. Are you up for teaching users a whole new system in a friendly digestible format?

Tim


-----Original Message-----
From: R-help <r-help-bounces using r-project.org> On Behalf Of Erin Hodgess
Sent: Monday, April 7, 2025 7:15 PM
To: CALUM POLWART <polc1410 using gmail.com>
Cc: r-help using r-project.org
Subject: Re: [R] An opinion question, please

[External Email]

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://st/
>> >at.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=05%7C02%7Ctebert%40ufl
>> >.edu%7C5d7c0eaa8685461444d008dd762a679f%7C0d4da0f84a314d76ace60a6233
>> >1e1b84%7C0%7C0%7C638796646703685961%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0
>> >eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIs
>> >IldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=s14fnEWWoF9o3dYaisEmpeDoq83UcUWz
>> >ZSBnYzqT%2BqM%3D&reserved=0
>> >PLEASE do read the posting guide
>> https://www/
>> .r-project.org%2Fposting-guide.html&data=05%7C02%7Ctebert%40ufl.edu%7
>> C5d7c0eaa8685461444d008dd762a679f%7C0d4da0f84a314d76ace60a62331e1b84%
>> 7C0%7C0%7C638796646703725541%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGki
>> OnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyf
>> Q%3D%3D%7C0%7C%7C%7C&sdata=dA8u3yXIsE8BS75%2F7xYuSb0XA%2FJW6Ftp8l8RtZ
>> jMoHo%3D&reserved=0
>> >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://sta/
>> t.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=05%7C02%7Ctebert%40ufl.e
>> du%7C5d7c0eaa8685461444d008dd762a679f%7C0d4da0f84a314d76ace60a62331e1
>> b84%7C0%7C0%7C638796646703743794%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1h
>> cGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUI
>> joyfQ%3D%3D%7C0%7C%7C%7C&sdata=3kYLerPAHv2JZWgoWasQqUwCTBum1hsL8dgeQT
>> b%2FFUo%3D&reserved=0
>> PLEASE do read the posting guide
>> https://www/
>> .r-project.org%2Fposting-guide.html&data=05%7C02%7Ctebert%40ufl.edu%7
>> C5d7c0eaa8685461444d008dd762a679f%7C0d4da0f84a314d76ace60a62331e1b84%
>> 7C0%7C0%7C638796646703761482%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGki
>> OnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyf
>> Q%3D%3D%7C0%7C%7C%7C&sdata=OnaeIdQfUI2pSZHp%2BzjmTb%2F%2FV3HUVFENFJnG
>> WlzN5BQ%3D&reserved=0 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.


More information about the R-help mailing list