在 R 中使用 S3 與 R6 的物件導向程式設計
Richie Cotton
Data Evangelist at DataCamp




library(R6) thing_factory <- R6Class( "Thing",private = list( a_field = "a value", another_field = 123 ))
a_thing <- thing_factory$new()
another_thing <- thing_factory$new()
yet_another_thing <- thing_factory$new()
R6Class() 定義類別產生器private 清單中new() 方法建立物件在 R 中使用 S3 與 R6 的物件導向程式設計