Читать книгу The Big R-Book - Philippe J. S. De Brouwer - Страница 207

Question #9

Оглавление

If you look careful at the code fragment above this question, you will notice that it is possible to provide an object my_cust_bank as attribute to the object my_inv_acc. This situation is similar to the code just above previous question, but unlike in the creation of also_an_account, now it works. Why is this?

To understand what happened here, we need to dig a little deeper.

my_inv_acc@custodian # our custodian bank is HSBC ## An object of class “Bnk” ## Slot “name”: ## [1] “HSBC” ## ## Slot “phone”: ## [1] “123123123” my_inv_acc@custodian@name # note the cascade of @ signs ## [1] “HSBC” my_inv_acc@custodian@name <- “DB” # change it to DB my_inv_acc@custodian@name # yes, it is changed ## [1] “DB” my_cust_bank@name # but our original bank isn't ## [1] “HSBC” my_cust_bank@name <- “HSBC Custody” # try something different my_inv_acc@custodian@name # did not affect the account ## [1] “DB” my_inv_acc@custodian@name <- my_cust_bank@name # change back

The Big R-Book

Подняться наверх