Methodical Thinking

Object-Oriented Programming with S3 and R6 in R

Richie Cotton

Data Evangelist at DataCamp

ch2_2-methodical-thinking.003.png

Object-Oriented Programming with S3 and R6 in R
methods
Object-Oriented Programming with S3 and R6 in R
methods("mean") # or methods(mean)
mean.Date     mean.default  mean.difftime mean.POSIXct 
mean.POSIXlt 
see '?methods' for accessing help and source code
Object-Oriented Programming with S3 and R6 in R

ch2_2-methodical-thinking.009.png

Object-Oriented Programming with S3 and R6 in R
methods(class = "glm") # or methods(class = glm)
add1           anova          coerce        
confint        cooks.distance deviance      
drop1          effects        extractAIC    
family         formula        influence     
initialize     logLik         model.frame   
nobs           predict        print         
residuals      rstandard      rstudent      
show           slotsFromS3    summary       
vcov           weights       
see '?methods' for accessing help and source code
Object-Oriented Programming with S3 and R6 in R

 

 

 

methods() returns S3 and S4 methods

Object-Oriented Programming with S3 and R6 in R
.S3methods(class = "glm")
add1           anova          confint       
cooks.distance deviance       drop1         
effects        extractAIC     family        
formula        influence      logLik        
model.frame    nobs           predict       
print          residuals      rstandard     
rstudent       summary        vcov          
weights       
see '?methods' for accessing help and source code
Object-Oriented Programming with S3 and R6 in R
.S4methods(class = "glm")
coerce      initialize  show        slotsFromS3
see '?methods' for accessing help and source code
Object-Oriented Programming with S3 and R6 in R

Summary

  • methods() finds methods for a generic
  • ... or for a class
  • .S3methods() finds only S3 methods
Object-Oriented Programming with S3 and R6 in R

Let's practice!

Object-Oriented Programming with S3 and R6 in R

Preparing Video For Download...