How it works…

The new() function is specially designed to define a new S4 class. In this recipe, the function robSum() is not a mandatory part of defining the S4 class, but this function has been used to calculate the summary statistics, and then, the output of this function has been encapsulated into the S4 class.

The robSum() function is an R function to calculate robust descriptive statistics. Then, the output of this function has been passed through the new() function to define the new S4 class robustSummary. The question is how do we check whether the object created using the new() function is an S4 object?

To check whether rStatsS4 is an object of class S4, you need to use the following code:

    > isS4(rStatsS4)
[1] TRUE

The output of the new S4 object will be as follows:

    > rStatsS4
An object of class "robustSummary"
Slot "median":
[1] 19
Slot "mad":
[1] 5.9304
Slot "q1":
[1] 16
Slot "q3":
[1] 23.75
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset