I have been trying to develop my S3 learnings. Have I used object
correctly here? I want to create a summary
and print
and plot
classes. I'm using a t-test for the moment but the function itself is not important - getting the S3 code right is.
Note: I've read everything i can find and recommended - but as they keep using sloop or lm I'm just not understanding what is unique or what is contained in those packages - i want to build from scratch. Thank you
library(gapminder)
library(dplyr)
library(ggplot2)
head(gapminder)
str(gapminder)
part3 <- gapminder
Asia1 <- subset(part3, continent == "Asia")
Africa1 <- subset(part3, continent =="Africa")
part3c <- rbind(Asia1, Africa1)
summary.part3s3b <-function(part3g) {
cat('The following should give t-test results:\n')
part3g <- t.test(data = part3c,
lifeExp ~ continent)
part3g
}
summary(part3g)