We will load data from a .csv file containing records customers, and we will instantiate a new class instance for each record. These records will be added to a list.
- Import the R6 library:
library(R6)
- Load the data from a .csv file:
customers = read.csv("./Customers_data.csv")
- We will now begin defining the R6Class structure. Note that we have two lists, one for the public attributes or methods, and another one for the private (these methods or attributes can only be accessed by other methods from this class). The initialize method is called whenever we create a new instance of this class. Note that we refer to the internal elements from this class using the self$ notation:
Customer = R6Class(public=list(Customer_id ...