[S] Re: Products of pairs

Simon Fear (fear@scmp.scm.liverpool.ac.uk)
Fri, 27 Mar 1998 19:01:35 GMT


> Is there a simple way to obtain the products of all possible pairs of
> values that are in a data frame column?

This recursive function will do it, not necessarily as quickly as some other
suggestions I'm sure you will get.

> cprods
function(x)
{
if(length(x) <= 1)
return(NULL)
else c(x[1] * x[-1], cprods(x[-1]))
}

Simon Fear

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news