Re: [R] apply fun to df returning a matrix

2010-04-30 Thread Soeren . Vogel
Thanks for the code, that was exactly what I was looking for. Regards, Sören On 30.04.2010, at 14:04, David Winsemius wrote: On Apr 30, 2010, at 6:59 AM, Mohamed Lajnef wrote: Hi Soeren Apply or aggregate functions Probably needs combn as well. Could do it all with numeric indices, b

Re: [R] apply fun to df returning a matrix

2010-04-30 Thread David Winsemius
On Apr 30, 2010, at 6:59 AM, Mohamed Lajnef wrote: Hi Soeren Apply or aggregate functions Probably needs combn as well. Could do it all with numeric indices, but this effort with character vectors seems acceptable: fun <- function(x){ cnms <- colnames(x) return(apply(combn(cnms,2), 2,

Re: [R] apply fun to df returning a matrix

2010-04-30 Thread Duncan Murdoch
On 30/04/2010 7:55 AM, soeren.vo...@eawag.ch wrote: Hi Mohamed, thanks for your answer. Anyway, the "how to" is exactly my problem, since ... fun2 <- function(x){ please_use_aggregate_and_apply_in_some_way_and_return_the_output_of_my_example_as_requested (fun(x)); } fun2(df); ... unfor

Re: [R] apply fun to df returning a matrix

2010-04-30 Thread Soeren . Vogel
Hi Mohamed, thanks for your answer. Anyway, the "how to" is exactly my problem, since ... fun2 <- function(x){ please_use_aggregate_and_apply_in_some_way_and_return_the_output_of_my_example_as_requested (fun(x)); } fun2(df); ... unfortunately returns an error ;-). Could you please give a

Re: [R] apply fun to df returning a matrix

2010-04-30 Thread Mohamed Lajnef
Hi Soeren Apply or aggregate functions best regards M soeren.vo...@eawag.ch a écrit : Hello, a data.frame, df, holds the numerics, x, y, and z. A function, fun, should return some arbitrary statistics about the arguments, e.g. the sum or anything else. What I want to do is to apply this functi

[R] apply fun to df returning a matrix

2010-04-30 Thread Soeren . Vogel
Hello, a data.frame, df, holds the numerics, x, y, and z. A function, fun, should return some arbitrary statistics about the arguments, e.g. the sum or anything else. What I want to do is to apply this function to every pair of variables in df, and the return should be a matrix as found wit