I'm trying to understand how to turn functions into object oriented programming in R. So for example, how could the data and 2 functions below be turned into one object using S3 (and then S4)? (Perhaps some other simple data and functions would serve better as examples?)
data <- c(1, 2, 3)
# Function 1
adding_1 <- function(x){
x <- x+1
}
# Function 2
subtracting_1 <- function(x){
x <- x-1
}
And how would below functions be executed using the OOP.
data1 <- adding_1(data)
data1
data2 <- subtracting_1(data)
data2