Don't you just need to use return? x <- 1 attr(x,'a') <- 'some text' f <- function(z) { attr(z,'a') <- 'some new text' return(z) } y <- f(x) y