Module #7 Assignment
For this assignment, I used the popular mtcars dataset for my analysis. My code is as follows: data("mtcars") head(mtcars) list(mtcars) #we can create generic functions for mtcars such as functions to find the #mean or a function to create plots such as bar or scatter plots. #S3 method class(mtcars) summary.mtcars <- function(object, ...) { summary(object) } summary(mtcars) #S3 methods can be applied #s4 method setClass("mtcarsClass", contains = "data.frame") mtcars_s4 <- new("mtcarsClass", mtcars) mtcars_s4 #S4 methods can be applied How do you tell what OO system (S3 vs. S4) an object is associated with? You can use the functions isS3method() and is4() How do you determine the base type (like integer or list) of an object? You can use the class function What is a generic function? A function that behaves according to the class it is applied to. What are the main differences between S3 and S4? S4 is more complex and structured than S3....