Greetings, I am trying to understand how to making a subset assignment function. Take the example where of making a "last" generic function.
last <- function(x,...) UseMethod("last"); last.numeric <- function(x, ...) x[length(x)] last.list <- function(x, ...) x[[length(x)]] ..... Now we run into the problem at hand if we want to assign something to the last item. Of course we could define a separate setter function, but I am not interested in this problem specifically, but understanding the method that would let me write the function to allow the following reasonable behavior. vec <- 1:5 last(vec)<-10 vec $ 10 Thank you for your time and expertise! -- View this message in context: http://r.789695.n4.nabble.com/Making-a-Subset-Assignment-function-tp4634717.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.