As shown here, an S3 value is both simple to set up and can be used by the generic function "list()" (said function can be used to interpret data of various types, thus the generic label). It does, however, require that a class be added afterwards should the programmer require it.
As we see here, S4 requires a bit more work in order to make a similar list. Unlike what we did for S3, S4 demands that the class for the list be set up before doing anything else, essentially ensuring it's part of the created list. The variables in the list being assigned individual slots is another difference it has with the S3 version, essentially allowing multiple inputs to be filtered into the same variable slot. Aside from the extra verboseness of S4, it's similar to S3 in almost every other way.
GitHub for code: https://github.com/Retrolovania/R_Programming/blob/main/Module%207.R
Comments
Post a Comment