Re: [R] transform input argument (matrix) of function

2012-11-17 Thread David Winsemius
On Nov 17, 2012, at 7:41 AM, Omphalodes Verna wrote: Dear list! I would like to write a function to transform matrix, which is input argument of a written function. It is easy with new matrix (see below), but my idea is to transform input argument (matrix) of function without any additio

Re: [R] transform input argument (matrix) of function

2012-11-17 Thread Rui Barradas
Hello, Your function fun2 (in fact both of them) changes a _copy_ of df1, not df1 itself. To have a copy of the output of fun2 you need to assign the value of fun2 outside it. df2 <- fun2(df1) Now df2 has what you want. (If I understand it well.) Hope this helps, Rui Barradas Em 17-11-2012 1

Re: [R] transform input argument (matrix) of function

2012-11-17 Thread R. Michael Weylandt
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 wrote: > Dear list! > >

[R] transform input argument (matrix) of function

2012-11-17 Thread Omphalodes Verna
Dear list!   I would like to write a function to transform matrix, which is input argument of a written function. It is easy with new matrix (see below), but my idea is to transform input argument (matrix) of function without any additional matrixes. Here is an example: fun1 <- function(xy) { x