Module 7: S3 and S4

 Module 7: S3 and S4

I did what I could do and I am taking more time to understand how that the object oriented side of R works. I was very confused on this entire Module, but since that this is crucial information, review on my own time is how I see to remedy my lack of understanding. I saw that the assignment was due at 8PM instead of AM, I was not sure and decided to try as hard as I could until the end to understand what to do, when, why and how. 

Questions:

1) S3 is quite generic and plain and is more of a 'one at a time' format where S4 has more formal classes that are inheritable and also can analyze and choose input from an array of arguments instead of a singular argument like S3

2) Using functions like class(), typeof() and even str() can help a user find out information about a dataframe

3) Generic Functions are like a universal, one size fits all type of function that can take a wide variety of input types and generate results. 

4) As stated in question 1, differences lie mainly in the formalities and the amounts of arguments that can be taken at one time.

##Module 7: S3 vs S4

## I submitted "late" but your time of submission was marked 8pm not 8am and was maintained at that time for the duration of the week

##If that was not the case we can e-mail and figure this out privately but I took the 8pm as literal and not a mistake, apologies Dr Friedman

library(dplyr)

library(tidyr)



data("airquality")


list(airquality,6)

head(airquality,6)


#Generic Functions may be assigned to variables within this dataset

## Lets See


airclass <- "air_class"


airquality <- list(data = airquality)


AC <- class(airquality) 


##S3 Function (generic)

GFAC <- function(x){

  (airquality$data)

}


GFAC(airquality)


##Let's try an S4


setClass("air_class", slots = list(""))

ac <- data.frame(airquality)

airthing <- new("air_class", data = ac)


GDAC <- function(x){

  

  summarise(airquality$data)


  }

Comments

Popular posts from this blog

R Package: pfStat

Module 7 Assignment

The Tampa Feasibility Report featuring R based Visualizations