Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 216
6.3.5 The .Data slot
ОглавлениеIf an S4 object inherits from an S3 class or a base type, R will give it a special .Data
slot that contains the data of this underlying object (S3 or base type):
# Here is the prototype of a dataset that holds some extra # information in a structured way. setClass(“myDataFrame”, contains = “data.frame”, slots = list(MySQL_DB = “character”, MySQL_tbl = “character”, data_owner = “character” ) ) xdf <- new(“myDataFrame”, data.frame(matrix(1:9, nrow=3)), MySQL_DB = “myCorporateDB@102.12.12.001”, MySQL_tbl = “tbl_current_accounts”, data_owner = “customer relationship team”) xdf@.Data ## [[1]] ## [1] 1 2 3 ## ## [[2]] ## [1] 4 5 6 ## ## [[3]] ## [1] 7 8 9 xdf@data_owner ## [1] “customer relationship team”
runif()
setClass()
new()