[R] An opinion question, please
Erin Hodgess
er|nm@hodge@@ @end|ng |rom gm@||@com
Tue Apr 8 01:15:18 CEST 2025
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]]
More information about the R-help
mailing list