Skip to content
Prev 332906 / 398506 Next

S4; Setter function is not chaning slot value as expected

On 11/09/2013 06:31 AM, daniel schnaider wrote:
Replacement methods (in R in general) require that the final argument (the 
replacement value) be named 'value', so

     setGeneric("CustomerID<-",
         function(x, ..., value) standardGeneric("CustomerID"))

     setReplaceMethod("CustomerID", c("Account", "character"),
         function(x, ...., value)
     {
         x at customer_id <- value
         x
     })

use this as

    CustomerID(ac) <- "54321"