How it works...
In Step 1, we create a new S4 class using the setClass() function. This takes the name of the new class as the first argument. The contains argument specifies which existing class we wish to inherit from (so that our new class will contain all of the functionality of this class plus any new stuff we create). The slots argument specifies the new data slots we want to add and requires that we give a type for them. Here, we're adding text data slots for the new barcode_id and barcode_sequence slots, so use character for both.
In Step 2, we create a constructor function. The name of this function must be the same as the class, and we specify the arguments we need to create a new object in the call to function(). Within the body, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access