
Last chance! 50% off unlimited learning
Sale ends in
defaultProps <- list(weight=1, color="blue", friends=c("Bob", "Alice"))
adat <- new("attrData", defaults=defaultProps)
## Get all defaults
attrDefaults(adat)
## Or get only a specific attribute
attrDefaults(adat, attr="color")
## Update default weight
attrDefaults(adat, attr="weight") <- 500
## Add new attribute
attrDefaults(adat, attr="length") <- 0
## Asking for the attributes of an element you haven't customized
## returns the defaults
attrDataItem(adat, x=c("n1", "n2"), attr="length")
## You can customize values
attrDataItem(adat, x=c("n1", "n2"), attr="length") <- 5
## What keys have been customized?
names(adat)
Run the code above in your browser using DataLab