Skip to content

transform input argument (matrix) of function

4 messages · Omphalodes Verna, R. Michael Weylandt, Rui Barradas +1 more

#
I'm afraid I don't really understand what you're searching for, but
note that your functions can be written without assignment/return:

fun3 <- function(x) invisible(cbind(xy[,1], xy[,2], xy[,1] + xy[,2]))

Cheers,
Michael

On Sat, Nov 17, 2012 at 3:41 PM, Omphalodes Verna
<omphalodes.verna at yahoo.com> wrote:
#
On Nov 17, 2012, at 7:41 AM, Omphalodes Verna wrote:

            
No, it should not be a three column matrix. When you call a function  
with an appropriate argument and fail fail to assign it to anything,  
the result evaporates.

?'<-'
?assign

Functions generally do not modify objects "in place". If you wanted to  
have df1 be the result of fun2(df1) you would have needed to do this:

df1 <- fun2(df1)

  There are ways to get around that limitation (described in each of  
those help pages), but I think it is better for one to learn ordinary  
functional programming conventions first.
This persistent practice after multiple postings to Rhelp  marks you  
as someone either having difficulty in reading the Posting Guide.